I'm looking for a way to convert letters to numbers, Like, 'a' = 1 kind of thing.
(p.s that doesn't work, I tried)
Its for a simple decrypt thing, Where say, G is the new A. So I put in, AAAA into my program, It will take A, Make it a 1, Add 7, then spit out a G. Or in this case GGGG. Or if I take AAAA and minus 2, It will spit out YYYY.
Suggestions will be great <3.
make dis 4 me kthx
A simple "decrypt" thing. Interesting, it sounds like you're attempting to make an industry grade encryption algorithm that will prosper in the world of applied and theoretical cryptography. It will surely revolutionize our thoughts with respect to security and our current standards. Everyone loves substitution ciphers, because they aren't easy to backdoor or trivially break, by any means. Gee. A word of advice, don't try to roll your own cryptographic algorithms. If you're making something for fun, cool. Anyways, to answer your original question: [url]http://pydoc.org/1.6/string.html#-atoi[/url]. Just so you're aware, I don't actually know Python, but I do know how to code. I simply used an amazing search engine known as Google to find "string to integer python". Additionally, you might want to look into making an array in the form of a standard hash table, which will allow for direct substitutions, it's much faster than what you are proposing and allows for easy extensibility and also unique keying, which your previous solution could offer only in a hacked up implementation.
[QUOTE=F33P;20677822]A simple "decrypt" thing. Interesting, it sounds like you're attempting to make an industry grade encryption algorithm that will prosper in the world of applied and theoretical cryptography. It will surely revolutionize our thoughts with respect to security and our current standards. Everyone loves substitution ciphers, because they aren't easy to backdoor or trivially break, by any means. Gee. A word of advice, don't try to roll your own cryptographic algorithms. If you're making something for fun, cool. Anyways, to answer your original question: [url]http://pydoc.org/1.6/string.html#-atoi[/url]. Just so you're aware, I don't actually know Python, but I do know how to code. I simply used an amazing search engine known as Google to find "string to integer python". Additionally, you might want to look into making an array in the form of a standard hash table, which will allow for direct substitutions, it's much faster than what you are proposing and allows for easy extensibility and also unique keying, which your previous solution could offer only in a hacked up implementation.[/QUOTE]
Way to be a dickbag.
Double Post.
[editline]05:38AM[/editline]
[QUOTE=F33P;20677822]A simple "decrypt" thing. Interesti...Blah blah blah... A word of advice, don't try to roll your own cryptographic algorithms. If you're making something for fun, cool. Anyways, to answer your original question: [url]http://pydoc.org/1.6/string.html#-atoi[/url]. .. Blah Blah Blah... for easy extensibility and also unique keying, which your previous solution could offer only in a hacked up implementation.[/QUOTE]
Thanks man, Your inspirational words have made me see the wrongs of my way, This "Google" search engine you speak of is new to me, The Link was also helpful.
Anyway, Say I have a list [1,2,3,4]
How does one "add" to each thing in said list, say, 4.
So it would be, [5,6,7,8].?
Then, For each integer in said list that is over 4, Take 4 from it.
Like, What command things would I use?
[code]
ciphertext = 'abcdefghijklmnopqrstuvwxyz'
shift = 400
while shift > 26:
shift = shift - 26
ciphlist = list(ciphertext)
end = len(ciphlist) + 1
ciphlist = range(1,end)
ciphlist = ciphlist + shift # Except, This doesn't work...
#"".join(ciphlist)
[/code]
Well, I'm glad the link was helpful to you. My intention was to actually help you without spoon feeding you. Apparently you didn't see that, so consider this as much help as you'll be getting from me. Maybe someone else, or perhaps the thousands of websites out there, can teach you how to turn a string in to an integer. Alternatively, you could learn to code for yourself instead of expecting everyone to hand you everything, and then acting like a jerk when someone comes along and feels like helping you. Fact is, you're just being lazy right now.
[QUOTE=Ortzinator;20678126]Way to be a dickbag.[/QUOTE]
Way to be useful to the thread there Ortzinator.
No, you were being an utter arsehole to someone simply wanting to know how to turn a letter into a number.
Use a list comprehension:
[code]
list = [element + 4 for element in list]
[/code]
Also, to get a numerical representation of a character, you can use the ord function: convert it back with chr. These are the numbers of the character on the ASCII symbol table, I believe.
[QUOTE=TheBoff;20683673]Use a list comprehension:
[code]
list = [element + 4 for element in list]
[/code]
Also, to get a numerical representation of a character, you can use the ord function: convert it back with chr. These are the numbers of the character on the ASCII symbol table, I believe.[/QUOTE]
Thanks man.
I'm glad I can help. List comprehensions can be a very powerful tool, as you can include conditionals:
[code]
list = [element + 4 for element in list if element < 4]
[/code]
And even multiple levels, but I've never had to use them enough to work out how they work.
[QUOTE=F33P;20677822]:words:[/QUOTE]
You do realize your oh-so-helpful one-second Google search resulted in a deprecated Python 1.x library that [b]doesn't work anymore.[/b]
[QUOTE=TehDoomCat;20741449]You do realize your oh-so-helpful one-second Google search resulted in a deprecated Python 1.x library that [b]doesn't work anymore.[/b][/QUOTE]
[cpp]
s = "100"
num = int(s)
assert num == 100
[/cpp]
Also found using Google, by the way. I really hope you're not trying to say that this isn't trivial to find using an online search.
edit:
Not that this isn't what he asked for. He wants the "chr" and "ord" functions, as mentioned by TheBoff.
[QUOTE=jA_cOp]Also found using Google, by the way. I really hope you're not trying to say that this isn't trivial to find using an online search.[/QUOTE]
Nah, I wasn't saying it *wasn't* trivial, just that that guy had clearly not even looked the link at or tried the functions he gave OP... proves that sometimes googling things leads to misinformation unless you already know what you're looking for.
[QUOTE=TehDoomCat;20742893]Nah, I wasn't saying it *wasn't* trivial, just that that guy had clearly not even looked the link at or tried the functions he gave OP... proves that sometimes googling things leads to misinformation unless you already know what you're looking for.[/QUOTE]
Sorry, I wasn't reading properly, your post makes more sense upon rereading. :)
Looks like F33P was just looking for a quick excuse to post about encryption, to be honest.
edit:
I think it's the broad quote that put me off. :v:
Sorry, you need to Log In to post a reply to this thread.