February 25, 2021, 03:02:21 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Vernam-Cipher | Encryption & Decryption by ozzi789 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Vernam-Cipher | Encryption & Decryption by ozzi789 [ 1+ years ago ] (Read 1089 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Vernam-Cipher | Encryption & Decryption by ozzi789 [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:43 AM »
Title :
Vernam-Cipher | Encryption & Decryption
Author :
ozzi789
Posted :
1+ years ago
Description :
Those two functions let you encrypt&decrypt strings easly with a provided password.
It is pretty secure with a strong & long password.
Only ways to break the encryption is:
-Bruteforce (yeah lol)
-Frequency analysis of the letters
Note for those who know how Vernam works:
My functions repeat the keyword/password if its shorter than the string you are manipulating
Code :
Code: BlitzBasic
;ozzi789 - 30.01.2012
original_string$=
"Vernam ist toll"
Print
"Original String: "
+original_string$
encrypted_string$= vernam_enc
(
original_string$,
"secret1"
)
Print
"Encrypted String: "
+encrypted_string$
decrypted_string$=vernam_dec
(
encrypted_string$,
"secret1"
)
If
original_string$=decrypted_string$
Print
"Decrypted String: "
+decrypted_string$
Else
Print
"This should not happen :'("
EndIf
Function
vernam_enc$
(
strng$,key$
)
len_strng=
Len
(
strng$
)
len_key=
Len
(
key$
)
key_index=
1
For
x=
1
To
len_strng
current_strng$=
Mid
(
strng$,x,
1
)
current_key$=
Mid
(
key$,key_index,
1
)
new_strng$=new_strng$+
Chr
(
Asc
(
current_strng$
)
+
Asc
(
current_key$
)
)
key_index=
(
x
Mod
len_key
)
+
1
Next
Return
new_strng$
End Function
Function
vernam_dec$
(
strng$,key$
)
len_strng=
Len
(
strng$
)
len_key=
Len
(
key$
)
key_index=
1
For
x=
1
To
len_strng
current_strng$=
Mid
(
strng$,x,
1
)
current_key$=
Mid
(
key$,key_index,
1
)
new_strng$=new_strng$+
Chr
(
Asc
(
current_strng$
)
-
Asc
(
current_key$
)
)
key_index=
(
x
Mod
len_key
)
+
1
Next
Return
new_strng$
End Function
Comments :
Guy Fawkes(Posted 1+ years ago)
SWEET! I can use this to encrypt my map data even further! Thanks, Ozzi! =D
ozzi789(Posted 1+ years ago)
Glad i could help !
SystemError51(Posted 1+ years ago)
I'll test this for data encryption/decryption in my game project. This is extremely interesting considering what I just read about the Vernam Cipher.// EDIT:It's working
virtlands(Posted 1+ years ago)
I love encryption stuff, thanks for posting 'Vernam-Cipher'.
Guy Fawkes(Posted 1+ years ago)
Can someone show an example or site that has this exact function only in PHP, javascript, jquery, or JSON?thanks!
virtlands(Posted 1+ years ago)
The Vernam Cipher {Crypto Museum} -- <font class="tiny"> <a href="
http://tinyurl.com/kzo37zx
" target="_blank">
http://tinyurl.com/kzo37zx
[/url] </font> Inside the world of Ciphers {in Java} -- <font class="tiny"> <a href="
http://tinyurl.com/m3wz2dw
" target="_blank">
http://tinyurl.com/m3wz2dw
[/url] </font>
Javascript
- simple vernam cipher -- <font class="tiny"> <a href="
http://tinyurl.com/nm47u22
" target="_blank">
http://tinyurl.com/nm47u22
[/url] </font> GitHub Gist Vernam Cipher in JS -- <font class="tiny"> <a href="
http://tinyurl.com/nast2jb
" target="_blank">
http://tinyurl.com/nast2jb
[/url] </font> Vernam Cipher in C# {CodeProject } -- <font class="tiny"> <a href="
http://tinyurl.com/l3cbyrf
" target="_blank">
http://tinyurl.com/l3cbyrf
[/url] </font> Vernam Cipher in Java {dream in code} -- <font class="tiny"> <a href="
http://tinyurl.com/n2zzz56
" target="_blank">
http://tinyurl.com/n2zzz56
[/url] </font>
zoqfotpik(Posted 1+ years ago)
This is essentially a one-time pad and thus is secure. But he says this:<div class="quote"> My functions repeat the keyword/password if its shorter than the string you are manipulating </div>If it does that, it is instantly zero security (due to differential cryptanalysis) so shouldn't be used for anything serious with keys shorter than the message. The problem with sufficiently long keys becomes key exchange.
Guy Fawkes(Posted 1+ years ago)
Then tell us, oh wise one. How would you fix this script then?
Matty(Posted 1+ years ago)
Use a key as long as the message....
dna(Posted 4 months ago)
When you use:
Code:
[Select]
VERNAM_DEC$(E$,Left$(K$,Rand(1,Len(K$))))
You get a partial answer to the original text. I did it this way to see if this could be a weak spot in the cypher.Is it?
Guy Fawkes(Posted 4 months ago)
Not if you do it right.~GF [/i]
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Vernam-Cipher | Encryption & Decryption by ozzi789 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal