0

I need a little help with the bytes();function in Python 3.5.
I hope I understand this properly, but bytes are a different way of storing a value, like 52 is 110100in binary. (Except binary is in bits right?) Anyway can somebody please tell me the following:

  • The proper syntax of bytes();(In use of a string)
  • Proper arguments the parameter "encoding" in bytes(str,encoding);
  • If I am completely mis-using this concept please tell me.

NOTE:

I am using this for weak cryptographic purposes. Please tell me how to:

Add a constant to every byte

And how to reverse aforesaid process.

How I am Using It:

str = "MyString";
data = bytes(str,*WHAT GOES HERE*);
print(data);
Expelliarmus
  • 11
  • 1
  • 2

1 Answers1

0

By importing codecs I can encode and decode it easily! Thanks @Jean-François Fabre!

import codecs
str = "Done!";
codecs.encode(str,"rot-13")
Expelliarmus
  • 11
  • 1
  • 2