Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:16:25+00:00 2026-06-12T10:16:25+00:00

As we all know, a computer works with numbers. I’m typing this text right

  • 0

As we all know, a computer works with numbers. I’m typing this text right now, the server makes a number out of it and when you want to read it, you’ll get text from the server.

How can I do this on my own?

I want to encrypt something with my own algorithm and my algorithm works fine with integers, but now I want to encrypt a String and I don’t know how to convert a Unicode string to an integer number and vice versa.

I’m using Python 3. Is there anybody who knows an elegant solution for my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:16:27+00:00Added an answer on June 12, 2026 at 10:16 am

    You are looking for the ord() function, I think:

    >>> ord('a')
    97
    >>> ord('\u00c2')
    192
    

    This gives you the integer number for the Unicode codepoint.

    To convert a whole set of characters use a list comprehension:

    >>> [ord(c) for c in 'Hello World!']
    [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
    

    It’s inverse is the chr() function:

    >>> chr(97)
    'a'
    >>> chr(193)
    'Á'
    

    Note that when you encrypt end decrypt text, you usually encode text to a binary representation with a character encoding. Unicode text can be encoded with different encodings with different advantages and disadvantages. These days the most commonly used encoding for Unicode text UTF-8, but others exist to.

    In Python 3, binary data is represented in the bytes object, and you encode text to bytes with the str.encode() method and go back by using bytes.decode():

    >>> 'Hello World!'.encode('utf8')
    b'Hello World!'
    >>> b'Hello World!'.decode('utf8')
    'Hello World!'
    

    bytes values are really just sequences, like lists and tuples and strings, but consisting of integer numbers from 0-255:

    >>> list('Hello World!'.encode('utf8'))
    [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
    

    Personally, when encrypting, you want to encode and encrypt the resulting bytes.

    If all this seems overwhelming or hard to follow, perhaps these articles on Unicode and character encodings can help out:

    • What every developer needs to know about Unicode
    • Ned Batchelder’s Pragmatic Unicode
    • Python’s Unicode HOWTO
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

you all know: right click -> zoom in or out in flash file, well,
I just want to know how this works out. I made a folder and
We all know it - this is the reading that lists the changes brought
We all know to set canvas's context property like this: ctx.textBaseline = top; ctx.shadowColor
We all know that most applications out there assume class names to follow the
Anyone know how the underlying replication model in sql server works? Do they essentially
If we have multiple sql server instances in a computer, how can we know
We all know that openId has become such a popular method for user authentication,
We all know of sleep method available in java threads.. I understand that the
We all know that CSS sprite images are great to reduce the amount of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.