SRL Archive - Other Scripts

1 Time Stamp Encrypter/Decrypter


Distort

2007-06-04 17:33:45

The idea behind this script was to create a encrypter/decrypter by means of something simular to a 1 time stamp. The only thing i did differently was avoid using the key for the first octlet, and instead opted for a easier to program "if theres a key number there, and a text number there in the first spot, the key will do something to it instead of placing the key for 4 spots and then the encrypted text".

You'll see if you read through it.

If you actually do read through it, you will find some comments but these are bits of debugging script i had to use (you cant imagine how annoying it is to put in TVK and end up getting out TTT, without debugging). Also, in your output you will also notice some numbers which dont appear to make much sence, these are also remaints from debugging, If you are encrypting text, the last number shown IS the encrypted next.

In the example key and cypher text i had used (key = '54756435454325324'; MSG = '74737230404327444914040013090305';) you will find the outcome will be THREE BLIND MICE.

If you'd like to comment on it, and/or suggest improvments, please feel free. Hell, if you want to complain about the remainder of debugging and sloppy coding (you dont use formating exactly correctly!!) then complain about it and i may decide to take it out, till then, have fun.


Forgot the mention : My scripting name = Pop, for some reason i think it was already registered here, but whatever.

If you want to know how 1 time stamps work, this site is good (and is my refference) http://www.disrespectcopyrights.net/archive/HowTo/how%20to%20use%20one-time%20pads%20for%20secret%20communications.txt
As i stated earlier, i decided to reject one of the ideas proposed, because it would have been harder to script, although i may decide to put it there later.

Smartzkid

2007-06-04 20:33:35

Interesting…


I'm going to look it over a bit more, but I don't think it could be too hard to crack, could it? (would take some handwork…)

Distort

2007-06-05 03:53:44

If you use the key more than once, it can be cracked, if not, it cannot be cracked.

Jason2gs

2007-06-05 12:39:59

I'll check it out later. Gotta go back to school now, though.

This uses a different encryption each time, and decodes it using a code attached inside of it?

Distort

2007-06-05 16:48:49

how a 1 time stamp works can be found on the link in my original post.

The jist of it however, is that you make a random number (do it by hand), and this will be your key. You then get your message, and make each letter into a number (ie a =01, z=26, doesnt matter what they are aslong as both you and your associate know both that and the key). You then add each number induvidually from the key to the induvidual numbers on the message using a falchoion method (if the answer gets to be more than 10, you take away 10)

For example, if my message was ABC, the message would be 010203. If my key were 43785432, i would add it like so:

0 1 0 2 0 3
4 3 7 8 5 4+ (the last 2 digits are ignored in this example)
4 4 7 0 5 7

You can only see the falchion method once in this example, and this is where i add the 2 to the 8. The answer to this is 10, so we take away 10 and get 0
Our final cyphertext would be:

447057

If you were trying to decypher this message alone, it would be impossible.
However, if you got 2 messages, and some of the letters were in the same place, you could get a good guess at part of the keys, and thus decypher part of it.

(IE, if i use aec (010503, cyphered would be 447357, you can see that the 44 and the 57 are the same, although it would take alot of guess work to get it right)

This is why its called a 1 time pad, you only use the key ONCE and only ONCE.

To convert the cypher text back to normal, you simply take away the key, if you get a negative number, you add 10 to the answer. IE in my case this would be it:

4 4 7 0 5 7
4 3 7 8 5 4-
0 1 0 2 0 3

since 0-8 = -2+10 = 2, you get the original text in the way you converted the character into a number. Hell, you can even change the numbers in my script to make it your own more, making it even harder to decrypt (supposing you send more than 1 message with the same key, who will know what the fuck the letters 582940 are (they could be my abc).

So if you and your aquitance only send 1 message with the same key, it will not be cracked (however, if you get a list of keys, variable lenghs, all random, and it should be quite a long list (hell, make a huge fucking array of them), you could cycle through it, and it would be practically impossible to crack).

However, i'd suggose to read the link, it is a good read (and so is alot of things on disrepect copyright)

Smartzkid

2007-06-05 16:55:10

Ahh

Now that I understand it better, I think this could be a lot of fun to play with

Do you think you could turn it into two main functions?

Function Encrypt(Key, Message: String) : String;
Function Decrypt(Key, Message: String) : String;

Also, how hard do you think it would it be to make a simple rsa encryption with scar?

Distort

2007-06-05 17:13:09

Yeh, i could make them into functions, i was planning to do it later for use with a form so i dont have to use the const as well as make it into a exe (after all, is basic pascal)

I'll check about the RSA encryption, not sure what it is right now.

Read about a RSA. it seems possible, but i'd require alot of math (more than whats shown on wikipedia, because you have to make it calculate everything to make sure that it is right) and it'd be complicated on scar

Smartzkid

2007-06-05 17:17:56

You have a private key and a public key

People can encrypt things with your public key and only your private key can decrypt them

I was thinking about making a 'friends list' scar form that would save people's names and their keys, but that really wouldn't make sense, as anyone who could send things to you could read anything sent to you by anyone with the same key

Distort

2007-06-05 17:49:32

These are the functions with example application.


program new;
var a:string;

function Encrypt(key, MSG: string): String;
var keyl, msgl, i, x, keyd, cryptb, keyc :integer;
var letter, a, keye, keya, keyb, crypta :string;
begin
result:='';
keyl:=length(key);
msgl:=length(MSG);
i:=1;
while i <= msgl do
begin
a:=copy(MSG, i, 1);
if (a='a') or (a='A') then letter:='01';
if (a='b') or (a='B') then letter:='02';
if (a='c') or (a='C') then letter:='03';
if (a='d') or (a='D') then letter:='04';
if (a='e') or (a='E') then letter:='05';
if (a='f') or (a='F') then letter:='06';
if (a='g') or (a='G') then letter:='07';
if (a='h') or (a='H') then letter:='08';
if (a='i') or (a='I') then letter:='09';
if (a='j') or (a='J') then letter:='10';
if (a='k') or (a='K') then letter:='11';
if (a='l') or (a='L') then letter:='12';
if (a='m') or (a='M') then letter:='13';
if (a='n') or (a='N') then letter:='14';
if (a='o') or (a='O') then letter:='15';
if (a='p') or (a='P') then letter:='16';
if (a='q') or (a='Q') then letter:='17';
if (a='r') or (a='R') then letter:='18';
if (a='s') or (a='S') then letter:='19';
if (a='t') or (a='T') then letter:='20';
if (a='u') or (a='U') then letter:='21';
if (a='v') or (a='V') then letter:='22';
if (a='w') or (a='W') then letter:='23';
if (a='x') or (a='X') then letter:='24';
if (a='y') or (a='Y') then letter:='25';
if (a='x') or (a='Z') then letter:='26';
if (a=' ') then letter:='00';
keyd:=i+(i-1);
keye:='';
keya:=copy(key, keyd, 2);
x:=1;
while x<=2 do
begin
keyb:=copy(keya, x, 1);
if keyb='' then keyb:='0';
crypta:=copy(letter, x, 1);
keyd:=strtoint(keyb);
cryptb:=strtoint(crypta);
keyc:= keyd+cryptb;

if (keyc>=10) then
begin
keyc:=keyc-10;
keyb:=inttostr(keyc);
keye:=keye+keyb;
end
else
begin
keyb:=inttostr(keyc);
keye:=keye+keyb;
end;
x:=x+1;
end;
x:=1;
result:=result+keye;
a:='';
i:=i+1;
end;
end;

function decrypt(key, MSG:string):string;
var cryptpart,cryptnumber, keynumber: string;
var cryptlength, keylength, b, f, i, a, ii: integer;
begin
result:='';
cryptlength:=length(MSG);
keylength :=length(key);
b:=1;
while b<=(cryptlength/2) do begin
cryptpart:='';
f:=0
i:=b+(b-1);
ii:=0
repeat
begin
cryptnumber:=copy(MSG,i+ii,1);
if (copy(key,i+ii,1))='' then
begin
keynumber:='0';
end
else keynumber:=copy(key,i+ii,1);
if (strtoint(cryptnumber))<(strtoint(keynumber)) then
begin
a:=strtoint(cryptnumber)+10;
cryptnumber:=inttostr(a);
end;
f:=(strtoint(cryptnumber))-(strtoint(keynumber));
if f>9 then f:=f-10;
cryptpart:=cryptpart+inttostr(f);
ii:=ii+1;
end;
until(ii=2)
if cryptpart='00' then cryptpart:=' ';
if cryptpart='01' then cryptpart:='A';
if cryptpart='02' then cryptpart:='B';
if cryptpart='03' then cryptpart:='C';
if cryptpart='04' then cryptpart:='D';
if cryptpart='05' then cryptpart:='E';
if cryptpart='06' then cryptpart:='F';
if cryptpart='07' then cryptpart:='G';
if cryptpart='08' then cryptpart:='H';
if cryptpart='09' then cryptpart:='I';
if cryptpart='10' then cryptpart:='J';
if cryptpart='11' then cryptpart:='K';
if cryptpart='12' then cryptpart:='L';
if cryptpart='13' then cryptpart:='M';
if cryptpart='14' then cryptpart:='N';
if cryptpart='15' then cryptpart:='O';
if cryptpart='16' then cryptpart:='P';
if cryptpart='17' then cryptpart:='Q';
if cryptpart='18' then cryptpart:='R';
if cryptpart='19' then cryptpart:='S';
if cryptpart='20' then cryptpart:='T';
if cryptpart='21' then cryptpart:='U';
if cryptpart='22' then cryptpart:='V';
if cryptpart='23' then cryptpart:='W';
if cryptpart='24' then cryptpart:='X';
if cryptpart='25' then cryptpart:='Y';
if cryptpart='26' then cryptpart:='Z';
result:=result+cryptpart;
b:=b+1;
end;
end;

begin
a:=encrypt('0101','AA');
writeln(a+#13);
a:=decrypt('0101',a);
writeln(a+#13);
end.

I've got some ideas for the functions, like sticking all your usernames and passwords into a seperate file, encrypted, whilst you have to remember your key, and when you want to use a script, in the setup you have to specify that key. Might be good so other people cannot gain access to your computer and know all your user names and passwords.

Anything else i cannot think of right now.

Widget

2007-06-10 03:35:02

From: Distort
These are the functions with example application.


if (a='a') or (a='A') then letter:='01';
if (a='b') or (a='B') then letter:='02';
if (a='c') or (a='C') then letter:='03';
if (a='d') or (a='D') then letter:='04';
if (a='e') or (a='E') then letter:='05';
if (a='f') or (a='F') then letter:='06';
if (a='g') or (a='G') then letter:='07';
if (a='h') or (a='H') then letter:='08';
if (a='i') or (a='I') then letter:='09';
if (a='j') or (a='J') then letter:='10';
if (a='k') or (a='K') then letter:='11';
if (a='l') or (a='L') then letter:='12';
if (a='m') or (a='M') then letter:='13';
if (a='n') or (a='N') then letter:='14';
if (a='o') or (a='O') then letter:='15';
if (a='p') or (a='P') then letter:='16';
if (a='q') or (a='Q') then letter:='17';
if (a='r') or (a='R') then letter:='18';
if (a='s') or (a='S') then letter:='19';
if (a='t') or (a='T') then letter:='20';
if (a='u') or (a='U') then letter:='21';
if (a='v') or (a='V') then letter:='22';
if (a='w') or (a='W') then letter:='23';
if (a='x') or (a='X') then letter:='24';
if (a='y') or (a='Y') then letter:='25';
if (a='x') or (a='Z') then letter:='26';

program New;
const letter = 'z';
var s:string;
begin
s := IntToStr(Ord(Uppercase(letter)[1])-64)
if (length(s)=1) then s := '0'+s;
writeln(s)
end.
You waste too much space :p

–

I made an encryption method of my own but I haven't bothered to reverse-engineer my own script yet. I did design it to be really confusing though, and it outputs un-pastable stuff, so it's only good for saving to and reading from files:
function Encrypt(s:string;a,b,c:integer):string;
var d,e,f,g,h,i,j:integer;
k,l,m,n,o,p:string;
begin
d := round(a+sqrt(b*b*c)-c*c) mod 256
d := max(d,-d) // positive is good
for e := 1 to length(s) do
begin
m := inttostr(ord(s[e])+d)
if length(m)<3 then
for h := 1 to (3-length(m)) do
m := '0'+m
k := k + m
end;
for f := 1 to length(k) do
if f < length(k) then
l := l + k[f+1]
else l := l + k[1]
for g := 1 to (length(l)/3) do
begin
for i := 1 to 3 do
begin
j := 3*(g-1)+i
n := n + l[j]
end;
o := o + chr(strtoint(n))
p := p + 'Chr('+inttostr(strtoint(n) mod 256)+')+'
n := ''
end;
result := o
end;

Distort

2007-06-10 07:11:49

Theres a better method? o.O

Thanks for pointing that out ^^

and yeh, by reverse engineer i supose you mean decrypt it?