Encryption of strings
1 Attachment(s)
Got a bit bored and decided to code my own little encryption thing.
It basically get's a string and converts it into an ASCII array, it then multiplies each item in the array by a "key" and encodes that with base64. The result ends up being relatively long but still pretty secure. I don't intend for this to be used for passwords so i'm releasing it. If you'd like to see what it does, iv'e attaches a screenshot. Here's the class, name it "Encryption": PHP Code:
PHP Code:
I originally wanted to return the binary of the strings but graal doesn't contain a default way to do it. Meaning i'd have to write a really long code and try to comprehend confusing formulas. |
Question: so your just doing this to each letter? Then encoding as Base64?
PHP Code:
Alot of times you will see people making a string.. like lets say "cat"... and encrypt the word "rabbit" for example.. r is encrypted depending on the first letter of the key.. "c".. a with "a"... b with "t".. b with "c".. going around in a circle using each letter from "cat".. also they will also use some sort of % math.. like 3%2 = 1... knowing it can only be a number of possibilities.. 256 char possibility. because if you do enough math to a single chracter.. lets say "41" which is hex for ASCII "a".. or "A".. I forget wether it's capital or lowercase at 41.. I think the other is 61? anyways.. if you did say num+10000000 that would result in more then 1 character to represent the character being encrypted... Just a thought tho. Sorry if this sounds confusing, I have worked 2 days and now running on about 4.5 hours of sleep.. bout to go to sleep and sleep my day away right now .. lol but any questions I would be glad to try and explain what I mean.. |
Little confused, I was thinking of creating a character map eg, a is equivalent to "7", b "K" and so on, but eh this way looked better.
And the reason I divide by 2 then multiply etc is to make it more confusing. If someone was trying to crack the string, without knowing the script they could probably tell it's using base64, then when they decipher it they'd see hang on each letter represents a number, and catch on. Where as this, it represents a number, but the number is "hashed" sort of. Never actually tried to encrypt information properly before, so this was more of a learning curve. |
Quote:
Here is an example of what I mean. Input PHP Code:
PHP Code:
PHP Code:
Xor Eample: PHP Code:
Since the size of the encrypted string is the same, we can just xor it again, by the same value, and it should decrypt the string ;) |
How would you get the binary of a string in GS2 O.o
I'm not really a math expert. I sort of understand what you mean. |
Quote:
PHP Code:
Play around with it a bit, see if you can make sense of the input/output.. post back here if u have more questins.. :) glad to help. |
The first rule of security is best phrased as "don't try to make your own, you'll **** it up". Pick an algorithm that's been well-researched and is known-strong to implement.
Quote:
|
As I stated and you quoted. This encryption isn't intended for a password, more of a fun little challenge.
|
Quote:
|
Quote:
|
Yeah, pretty much sums it up.
A way of using this would be to store the "encrypted" string in a database then have the server compare what the "encrypted" user input. So theoretically it could be used. |
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
|
All times are GMT +2. The time now is 05:36 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.