Author Topic: encrypt decrypt project  (Read 7478 times)

0 Members and 1 Guest are viewing this topic.

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: encrypt decrypt project
« Reply #15 on: March 13, 2021, 02:27:17 pm »

Sorry, the thread says encrypt decrypt didn't mean to hi-jack. I thought I was completing the thought about encryption decryption you left unfinished.

But then I have to say it is not clear to me what your project is about.

And I suggest you post project code in Programs Board so it's not mistaken as a discussion or a question.

All good.

I originally put that up because the other night i could not find a simple encrypt decrypt here when I searched(just being lazy as I was not focusing on writing another routine while working on the main app). I found one, but not quite what I was looking for, and did not want to ask to have someone put one up for me. So did a little research, did some converting, and learned about a cipher I was not familiar with,  and posted it here in case someone else was looking as well. Just giving back to the community.

As far as My app, I use that in is my own personal password manager. Lastpass got annoying and don't like all the others that have more than I need or want to charge, or both, so whipping up something quick and easy, while trying to keep it "sorta" secure :-) All locally stored, no cloud. I'll post it here when I am done, others can fool around with it to their liking

I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: encrypt decrypt project
« Reply #16 on: March 14, 2021, 02:57:59 pm »
It is good, my cryptogram code is 100% improved from that old Inform project, clean cut now.

I look forward to comparing methods :)
« Last Edit: March 14, 2021, 02:59:53 pm by bplus »

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: encrypt decrypt project
« Reply #17 on: March 27, 2021, 08:36:31 am »
I am going to leave this here unless someone thinks I should make a new thread:

OK. So need help with something. fortunately I found my key - but earlier I could not, and realized I locked myself out of my own program. skip the discussion of the ethics of adding this feature or not...

without knowing the key, but knowing the function. how can I write a reverse function to pull the key when everything is coded to the key.

example
I use a

Code: [Select]
str_crypt username+"*"+pw+"*"+key, key, "e"
Or is this not really possible.?


Code: [Select]
Function STR_CRYPT$ (strPlainTxt As String, strKey As String, method As String)
        '/ This encryption uses a key in addition to a pw.
        Dim i, c As Integer
        Dim strBuff As String


        If Len(strKey) Then
                For i = 1 To Len(strPlainTxt)
                        c = Asc(Mid$(strPlainTxt, i, 1))

                        Select Case method
                                Case "d":
                                        c = c - Asc(Mid$(strKey, (i Mod Len(strKey)) + 1, 1))
                                Case "e":
                                        c = c + Asc(Mid$(strKey, (i Mod Len(strKey)) + 1, 1))
                        End Select

                        strBuff = strBuff + Chr$(c And &HFF)
                Next i
        Else
                strBuff = strPlainTxt
        End If
        STR_CRYPT$ = strBuff
End Function


been working on it for a bit. so now I think i cannot see the forest for the trees

I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: encrypt decrypt project
« Reply #18 on: March 27, 2021, 12:05:22 pm »
Well not sure I can answer your question but here is a tip:
c = Asc(Mid$(strPlainTxt, i, 1))

can be written as c = Asc(strPlainTxt,i) which might save time and add clarity.

In QB64 ASC() is not restricted to first char anymore.
« Last Edit: March 27, 2021, 12:07:39 pm by bplus »

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: encrypt decrypt project
« Reply #19 on: March 27, 2021, 12:26:09 pm »
Well not sure I can answer your question but here is a tip:
c = Asc(Mid$(strPlainTxt, i, 1))

can be written as c = Asc(strPlainTxt,i) which might save time and add clarity.

In QB64 ASC() is not restricted to first char anymore.

o!
thanks for that tip. thats just a quicky enc/dec function for now while I am working on the program. I have another app that will convert the final version if/when it is done that will convert the db and the account to the new encryption.

I followed a format the Lastpass, authy and a few others follow. You loose the key you loose your data - and to think I was snippy with Authy LOL, I could not remember my key, and distinctly said - "...devs are not going to lock themselves out of their own app" LOL oops!
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: encrypt decrypt project
« Reply #20 on: March 27, 2021, 12:28:08 pm »
 has anyone tried to make a hill encryption with QB64? I love it, but simple on paper - although long, but converting it to programing ... hmmmm
« Last Edit: March 28, 2021, 12:28:06 pm by xra7en »
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline Parkland

  • Newbie
  • Posts: 51
    • View Profile
Re: encrypt decrypt project
« Reply #21 on: April 04, 2021, 10:10:48 pm »
Neat ideas here!

I made something similar years ago using the RND function along with RANDOMIZE(X) seed command. I found that the RND function would always return the same random values so using the seed number as the password, you could add random 0-255 values to the character ASCII values and encrypt/decrypt that way.

I don't think the RND function would be very good for random numbers for encrypting something that couldn't be broken though, I think it's mostly just for game quality random numbers.

Right now I'm fiddling with some encryption to use for network data transfer and think I'll use maybe a key file shared between users which will be random numbers, maybe several kilobytes, then the sending computer can send an offset number with a packet of what part of the key file to use for the decryption. That way for now the key files can be generated with the RND function but later maybe something more elaborate and harder to crack.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: encrypt decrypt project
« Reply #22 on: April 05, 2021, 12:07:42 am »
Basically generate some random bytes say, 1 GB and make the offset into the file public

Have to figure out a way to send the 1GB file to Alice and Bob. Been working on a that. 

Hash functions can be used to generate random bytes
« Last Edit: April 05, 2021, 12:10:23 am by NOVARSEG »

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: encrypt decrypt project
« Reply #23 on: April 05, 2021, 03:28:49 am »
That is called a one-time pad.

As you've identified, securely communicating the pad to the recipient is hard enough that you may as well just send them the actual content

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: encrypt decrypt project
« Reply #24 on: April 05, 2021, 08:52:42 am »
I have a friend who uses a simple series of encryptions for things, and then sends the proper method value to an user.

For example, the first thing they do is zip a file.  (Think _DEFLATE.)  Then he has a series of simple encryption methods to choose from:

Method 1: NOT every byte
Method 2: Write the file in 10 byte chunks — backwards.
Method 3: Use a substitution cypher.  A = Z.  B = W.  Ect...
Method 4: Use a shift-cypher.  A = C.   B = D.  C = E.  (Shift value X spaces.)
And so on...

Then you just send the user the proper method number to enter as a passcode (usually obfuscated as well, with a simple math formula.  Number 1234567 has the digits add up to 28, which corresponds to a valid method, just as an example.)

None of the processes are overly complex on their own, but they generally render the files secure from meddling/alteration.  Unless they’re reversed properly, about the best anyone can ever get from them is a “archive corrupted” message.

By themselves, they probably wouldn’t be hard to break, but by using them on compressed information,  he’s never had an issue with them so far.  (Of course, we’re not talking securing the US Nuclear Missile launch here; just simple game asset data, and such...)

A lot of times, people tend to overthink how complex encryption has to be, when something *very* simple is sufficient enough for their needs.  If I were to just compress the game data for *anything* I’ve ever shared here on the forums, and then wrote it to a file BACKWARDS, is there anybody who’d expend the effort to sit down and sort that out?

99.9987% of pseudo-encryption security comes simply from, “Meh!  It’s encrypted.  It’s not worth the effort to deal with!”
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!