0

In Java, what's the best library/method to map a 13-character string to a 3-character string for the error check purpose? Thanks!

1
  • What's hcheck ? Is that a library you use ? Commented Aug 30, 2012 at 6:46

2 Answers 2

1

There isn't a built-in method for this. You could implement a 24-bit CRC, if you really mean 3 bytes rather than characters.

If you do mean char, what characters do you accept in the output? Only ASCII? Any Unicode character?

Sign up to request clarification or add additional context in comments.

1 Comment

CRC is similar to what I want. Yes, ASCII is what I want.
1

The simplest approach would be to use the hashCode()

int threeByteHash = string.hashCode() & 0xFFFFFF;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.