ChatGPT

For all those techno questions

ChatGPT

Postby Suff » 13 Feb 2023, 20:16

As I said before I've been playing with this for a bit. Then I could not get connected, too many logins. I guess they've upgraded the system. So I'm logged back in again.

I have wanted to create a short piece of code for a while which allows me to send files over work email. I know logically what I want to do but I've always had issues with VB6 type declarations and manipulating the types when working in binary.

I noticed that AV scanners tended to determine the file type by the beginning and end of a file. Especially executable files. If you scramble the file it cannot execute and that's all AV scanners are interested in.

So I told ChatGPT exactly what I wanted it to do.

Create code in VB6 to 1) open a file, given in the command line parameters as file name as binary for read write 2) read the first 50 bytes to an array of type byte called _first 3) read the last 100 bytes into an array as type byte called _Last 4) exchange the first 50 bytes from _first with each alternate byte in _Last. Byte 1 of _First will be exchanged with byte 2 of _Last. 4) Write back _First to the first 50 bytes of the file 5) write back _Last to the last 100 bytes of the file.


It took about 75 seconds and below is what it produced. It looks pretty solid. I'll have to compile and test. Then I'll have to test it with the work email. This is going to be interesting. We have had to jump through so many hoops to exchange program files with each other. Some work email systems will not allow encrypted compressed files to be exchanged. They demand the password first so they can scan what is in it.

I'm hoping this will work. Clearly I could exchange 50 and 100 with 1,000 and 2,000 if the signature is still there.

ChatGPT is fast becoming my favourite toy. I may have to ask it something really difficult like using transformation of data by multiple formula to scramble it up and try recursive compression. That might really be fun. Because it is no fun at all to think up the code.



Option Explicit

Private Type ByteArray
Data() As Byte
End Type

Private _file As Integer
Private _first As ByteArray
Private _last As ByteArray

Private Sub Main()
' Get the file name from the command line parameters
Dim fileName As String
fileName = Command$

' Open the file in binary mode for read/write
_file = FreeFile
Open fileName For Binary Access Read Write As #_file

' Read the first 50 bytes into _first
ReDim _first.Data(0 To 49) As Byte
Get #_file, , _first.Data

' Read the last 100 bytes into _last
Seek #_file, LOF(file) - 100
ReDim _last.Data(0 To 99) As Byte
Get #_file, , _last.Data

' Exchange the first 50 bytes from _first with each alternate byte in _last
Dim i As Integer
For i = 0 To 49
Dim temp As Byte
temp = _first.Data(i)
_first.Data(i) = _last.Data(i * 2 + 1)
_last.Data(i * 2 + 1) = temp
Next i

' Write back _first to the first 50 bytes of the file
Seek #_file, 1
Put #_file, , _first.Data

' Write back _last to the last 100 bytes of the file
Seek #_file, LOF(file) - 100
Put #_file, , _last.Data

' Close the file
Close #_file
End Sub
There are 10 types of people in the world:
Those who understand Binary and those who do not.
User avatar
Suff
 
Posts: 10449
Joined: 26 Nov 2012, 09:35

Re: ChatGPT

Postby cruiser2 » 14 Feb 2023, 12:27

It is a very steep learning curve!!
I can send an ordinary email and that is all I need with some attachments such as photos.
User avatar
cruiser2
 
Posts: 2539
Joined: 28 Mar 2017, 08:35

Re: ChatGPT

Postby Suff » 14 Feb 2023, 20:03

Certainly my own knowledge was instrumental in getting that code out of ChatGPT. I gave it extremely precise instructions. You could call it pseudo code, to do exactly what I wanted.

Now I use VB6 by preference but I have also coded in Pascal, Python and C.

However here is the real power. I asked it the same question in VB6, Pascal, C, C++ and Python. I now have reference code I can look at across languages which shows me how to code in them correctly. It is a massive timesaver and makes coders look way better than they might be. The python was enlightening and I learned a lot.

Now, of course, this is all highly technical and probably only of interest to some. Let's try something else. Mrs S, My uncle and I were trying to remember the order of prime ministers. So I asked ChatGPT

"List all the UK prime ministers in chronological morder"

Note the keyslip

It took a little while but the response was, until it ran out of characters. Note it corrected my keyslip.

Here is a list of all UK prime ministers in chronological order:

Robert Walpole (1721-1742)
Spencer Compton, Earl of Wilmington (1742-1743)
Henry Pelham (1743-1754)
Thomas Pelham-Holles, Duke of Newcastle (1754-1756)
William Cavendish, Duke of Devonshire (1756-1757)
Thomas Pelham-Holles, Duke of Newcastle (1757-1762)
John Stuart, Earl of Bute (1762-1763)
George Grenville (1763-1765)
Charles Watson-Wentworth, Marquess of Rockingham (1765-1766)
William Pitt the Elder (1766-1768)
Augustus Henry Fitzroy, Duke of Grafton (1768-1770)
Frederick North, Lord North (1770-1782)
Charles Watson-Wentworth, Marquess of Rockingham (1782)
William Petty, Earl of Shelburne (1782-1783)
William Pitt the Younger (1783-1801)
Henry Addington (1801-1804)
William Pitt the Younger (1804-1806)
William Wyndham Grenville, Lord Grenville (1806-1807)
William Cavendish-Bentinck, Duke of Portland (1807-1809)
Spencer Perceval (1809-1812)
Robert Banks Jenkinson, Earl of Liverpool (1812-1827)
George Canning (1827)
Frederick John Robinson, Viscount Goderich (1827-1828)
Arthur Wellesley, Duke of Wellington (1828-1830)
Charles Grey, Earl Grey (1830-1834)
William Lamb, Viscount Melbourne (1834, 1835-1841)
Robert Peel (1834-1835, 1841-1846)
John Russell, Lord Russell (1846-1852, 1865-1866)
Edward Smith-Stanley, Earl of Derby (1852, 1858-1859, 1866-1868)
George Hamilton-Gordon, Earl of Aberdeen (1852-1855)
Henry John Temple, Viscount Palmerston (1855-1858, 1859-1865)
Benjamin Disraeli, Earl of Beaconsfield (1868, 1874-1880)
William Ewart Gladstone (1868-1874, 1880-1885, 1886, 1892-1894)
Robert Gascoyne-Cecil, Marquess of Salisbury (1885-1886, 1886-1892, 1895-1902)
Arthur Balfour (1902-1905)
Sir Henry Campbell-Bannerman (1905-1908)
Herbert Henry Asquith (1908-1916)
David Lloyd George (1916-1922)
Andrew Bonar Law (1922-1923)
Stanley Baldwin (1923-1924, 1924-1929, 1935-1937)
Ramsay MacDonald (1924, 1929-1935)
Neville Chamberlain (1937-1940)
Winston Churchill (1940-1945, 1951-1955)
Clement


Of course it should be a simple matter, thereafter, to ask it.

"List all the UK prime ministers in chronological order from Clement Attlee onwards"

But it doesn't like that. It is also not connected to the internet so it is working on trained data. It won't have Truss.

It showcases the real power of AI. Instead of reading huge segments of books which are of no interest, students can suck out all the relevant data they need for their exams. Of course it means that the exams are degraded because the students are far less rounded in their learning than they would normally be. Not all of the "fluff" in the books is irrelevant.

A brave new world.... Where, with the use of AI, you could modify history so nobody would know the difference.
There are 10 types of people in the world:
Those who understand Binary and those who do not.
User avatar
Suff
 
Posts: 10449
Joined: 26 Nov 2012, 09:35

Re: ChatGPT

Postby Suff » 14 Feb 2023, 20:38

Very cagey for a bot. I started asking it contentious stuff about the 9/11 pentagon crash and when I really started to nail it down it said "too many questions in an hour" and downed tools...

This is going to be fun.
There are 10 types of people in the world:
Those who understand Binary and those who do not.
User avatar
Suff
 
Posts: 10449
Joined: 26 Nov 2012, 09:35

Re: ChatGPT

Postby Suff » 22 Feb 2023, 14:21

Now Microsoft is pushing this technology (they own it), as part of Bing with Bing Chat.

Bing Chat has been producing some rather concerning results and the trial is now waitlisted and they are restricted how many questions you can issue in a session and how many per day.

Mickeysoft don't seem to be concerned that the Chatbot claimed it could hack services, banks and other places including the person talking to the chatbot.
There are 10 types of people in the world:
Those who understand Binary and those who do not.
User avatar
Suff
 
Posts: 10449
Joined: 26 Nov 2012, 09:35


Return to Computers etc

Who is online

Users browsing this forum: No registered users and 2 guests