Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I'd like to create a PSK key to use with TLS-RSA-PSK-WITH-AES-256-CBC-SHA - what is the format of this key?

share|improve this question

closed as off-topic by e-sushi, figlesquidge, Gilles, AFS, DrLecter Mar 19 at 21:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
This question does not appear to be about cryptography within the scope defined in the help center… it is software recommendation request. –  e-sushi Mar 19 at 20:38
1  
This question appears to be off-topic because it is about the programming aspects of using a cryptographic library, and best answered by reading the documentation anyway. –  Gilles Mar 19 at 20:56

1 Answer 1

up vote 1 down vote accepted

I would use the Interactive Ruby (irb) command.

  bash> irb
  irb> require 'securerandom'
=> true
  irb> SecureRandom.base64(256/8)
=> "qOo64focYhXyCPH3z5zpKyhNqQmTgtAVIP4mgJFnjrM="

This will produce a cryptographically secure random bit sequence, encoded in base64. This one is 32 bytes or 256 bits long. If you prefer hex format, try this:

  irb> SecureRandom.hex(256/8)
=> "a66d258de75987d31a4537ecd1ff7a34517bf92f2c07abb20fa0fb517f2491f1"
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.