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 1113457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:51:38+00:00 2026-05-17T02:51:38+00:00

I am looking for an algorithm to encrypt secret numbers on a mobile device

  • 0

I am looking for an algorithm to encrypt secret numbers on a mobile device with these properties:

  • Each number has a name associated by the user which is stored in cleartext but may be used to perturb the encryption
  • The number has to be encrypted with the password without revealing a hint about whether a given password is right or wrong
  • When decrypting with a wrong password, the result has to be a number with equal length (i. e. when the original was 4 digit, the wrong one has to be 4 digit as well)
  • When an attacker knows one or a few of the numbers, the easiest way of getting the other numbers should be to brute-force the password until the numbers decrypt to that value.
  • It may optionally support other character sets (i. e. 0-9a-f, or 0-9a-zA-Z) – the character set will be stored with the entry and every wrong decryption will reveal only these characters of course
  • I assume that an attacker who acquired the mobile device will find a way to dump the encrypted data from it and re-implement the algorithm or any cracking logic, so even when having access to the raw data, it should not reveal information about wrong passwords

As I have SHA-1 available on the device, i was thinking of the following:

  • Find the smallest number of bytes where all values of the range can be stored into (for a 3-digit number, use 2 bytes, as 999 does not fit into one byte)
  • take the number to encrypt, and test how often you can add 10**digitcount to it so that it still fits into the range, i.e when encrypting number 555, this is 64, as 65555 > 65536, but when encrypting 222, it is 65, as 65222 < 65536.
  • Pick a random number from 0 to the number you determined in the last step (linear distribution) and add number*(10**digitcount) to the number to encrypt
  • The result should be a number that is somehow equally distributed over the whole byte range.
  • Take SHA-1 of name+password, cut off the first (or last) bytes – as many as needed to cover the number from the last step – and XOR them with the number from the last step.
  • Store the Xor-ed SHA1, the length of the number, and the name.
  • Adaptation to other bases than 10 is easy, which can fulfill the optional requirement above.

What do you think? Any ideas to improve it? Any simpler ways to achieve the same? Any obvious flaws I missed?

(And are there any (free as in speech) applications for mobile devices that implement a similar algorithm?)

(Or are there any other stackexchange websites where this question fits better?)

edit: I now accepted the only answer that does not try to tell me the requirements are wrong. Yes, I know the requirements are wrong, but the alternative (store all your PINS in clear text or weakly encrypted on your mobile device) definitely is the larger evil.

  • 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-05-17T02:51:39+00:00Added an answer on May 17, 2026 at 2:51 am

    Just to provide you with an idea for a simpler approach: Use the good old DLP in finite cyclic groups.

    Additively written: cipher = plain + key mod 10^number-of-digits
    then clearly: cipher - key mod 10^number-of-digits = plain again, and it’s always going to be in the target interval by design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for algorithm scroll number For example; I have an array which has
I'm looking for an algorithm which someone has access to that will compute the
I am looking for a simple and FAST algorithm to encrypt/decrypt a string (length
I am looking for an algorithm which, given a set of numbers {0, 1,
I am looking for an algorithm that will take numbers or words and find
I'm looking for an algorithm that can check if nested regex repeats are reducible.
I am looking for an algorithm to generate equally distributed points inside a polygon.
I'm looking for an algorithm to find the common intersection points between 3 spheres.
I am looking for a algorithm that takes a string and splits it into
I am looking for an algorithm to convert between HSL color to RGB. It

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.