Skip to main content
22 votes
Accepted

HMAC correct on 11.2 but wrong and different on 11.3 running same code

Indeed, Hash has changed for 11.3 in several ways. The one relevant here is that strings are now hashed according to their UTF-8 representation. As a simple ...
ilian's user avatar
  • 25.5k
13 votes
Accepted

Elliptic curve cryptography in Mathematica

A few updates, since Wolfram has added a lot of cryptography functionality in recent versions. Here is a link to the guide page for Cryptography functions in the Wolfram Language: https://reference....
Arnoud Buzing's user avatar
9 votes
Accepted

Is it possible to convert the output of the Encrypt[] function into binary digits?

I will turn Kuba's comment into an answer. The EncryptedObject you create using Encrypt contains the encrypted data and the ...
M. Stern's user avatar
  • 1,159
8 votes
Accepted

Computing point operations on an elliptic curve over a finite field

There probably is some way to do this using built-in functionality, but anyhow, here is an implementation of the group law (use at your own risk): ...
user293787's user avatar
  • 11.9k
7 votes

Extract every nth character from a string

StringTake and Span would be useful. For example, to get the second characters: ...
JungHwan Min's user avatar
  • 4,684
7 votes
Accepted

How to return two values from function

You almost have this correct (I think). You don't need to use Return (check the documentation, it doesn't do what you think). The result of a module is simply the ...
mikado's user avatar
  • 16.8k
6 votes
Accepted

Nested BlockchainBlockData fail

The example accesses the blockchain too rapidly. If we add the option FailureAction->None to the first query, we see the error message: BlockchainBlockData::...
WReach's user avatar
  • 69.1k
6 votes
Accepted

How do I generate a JSON Web Token?

I stole the HMAC from here https://mathematica.stackexchange.com/a/167636/72682. The header/payload/secret are the same as the ones on the Wikipedia page https://en.wikipedia.org/wiki/JSON_Web_Token. ...
flinty's user avatar
  • 25.6k
5 votes

What are some use cases of Wolfram Blockchain?

BlockchainBlockData[1221, BlockchainBase -> {"Multichain", "Wolfram"}] https://www.multichain.com/blog/2017/03/wolfram-mathematica-multichain-integration/ ...
Alexey Golyshev's user avatar
5 votes

How can I encrypt/decrypt a directory?

If you've upgraded to wolfram 12 now, its pretty simple: To encrypt ...
ions me's user avatar
  • 991
5 votes
Accepted

Why can't Encrypt handle messages bigger than very small?

When using GenerateAsymmetricKeyPair the key size must be longer than the message. So the following works. ...
m_goldberg's user avatar
  • 108k
5 votes

How to construct addition and multiplication table for finite field?

p = X^4 + X + 1; mod[x_] := PolynomialMod[x, p, Modulus -> 2] elements = mod[Plus @@@ Subsets[X^Range[0, 4]]] And the tables are: ...
Henrik Schumacher's user avatar
5 votes
Accepted

Couldn't load OpenSSL library in 12.1 (Windows)

A likely fix for this issue has been released with the CURLLink 12.1.1 paclet update. This update will not be automatically installed, but can be acquired by evaluating ...
ilian's user avatar
  • 25.5k
5 votes

How to get v12.0 to print PGP public key and secret key BLOCKS after generating a key pair using GenerateAsymmetricKeyPair[]?

UPDATE: Partial implementation of RFC 2440 to generate a Public Key ASCII armor block from GenerateAsymmetricKeyPair[]. The Base64 data will include 3 types of ...
Jean-Pierre's user avatar
  • 5,197
5 votes
Accepted

How to decrypt a signed RSA message without using private/public key in Mathematica?

This is very easy to adapt from my other answer, but without using PublicKey / PrivateKey, ...
flinty's user avatar
  • 25.6k
4 votes
Accepted

Is this decryption function idiomatic?

Expressive enough for my taste. But a bit shorter and much faster (by 3 orders of magnitude) would be to use ToCharacterCode and ...
Henrik Schumacher's user avatar
4 votes
Accepted

Number theory in Mathematica

A course in computational number theory by David Bressoud and Stan Wagon (Wiley, 2000)
David G. Stork's user avatar
4 votes

RSA encryption/decryption with signed message

I've written this out using Mathematica's PublicKey / PrivateKey as this is the way you should be doing crypto in v10.1+. But ...
flinty's user avatar
  • 25.6k
3 votes

how to scramble and then unscramble a list of elements?

...
Wouter's user avatar
  • 1,343
3 votes

Applying Polybius cypher

...
Henrik Schumacher's user avatar
3 votes

User Implemented SHA-1 is failing for strings of length >512 bits

The following changes to the beginning of the code (all before the first For[] loop) fixes the code for any amount of bits/ bytes. ...
Shinaolord's user avatar
3 votes

Can I make a SymmetricKey with my own key value?

Hopefully I don't misunderstand your question. We can look at the input form of the SymmetricKey using, appropriately, InputForm...
Mr.Wizard's user avatar
  • 272k
3 votes

J/Link HMAC Base64

The recently released version 11.3.0 introduced BaseEncode which would be useful here. A complete example (including the HMAC computation) in Mathematica: ...
ilian's user avatar
  • 25.5k
3 votes
Accepted

J/Link HMAC Base64

Use Base64`encodeBase64String -- with a capital "B". The expression: ...
WReach's user avatar
  • 69.1k
3 votes

Can't use keys of less that 64 bits long

Sometimes the documentation is misleading. According to Wikipedia, Blowfish keys should be between 32 and 448 bits. For some reason, Encrypt insists a Blowfish key ...
m_goldberg's user avatar
  • 108k
3 votes

How can I add a different value to each item in a list?

Do you want something like this? ...
A.Z.'s user avatar
  • 580
3 votes

How to permute elements in a list

...
flinty's user avatar
  • 25.6k
3 votes
Accepted

Find prime numbers two prime numbers given a certain constraint

If $n$ is the product of two distinct primes, $p$ and $q$, then $\varphi(n) = (p-1)(q-1) = pq -p -q +1 = n -p -q +1$ which is enough information to find the factorization. I.e., you know $pq=n$ and $...
yarchik's user avatar
  • 19.1k
2 votes
Accepted

Why is there a lot of noise in the Wolfram Blockchain?

Some of those transactions contain expressions added to the Wolfram blockchain using BlockchainPut and you see that as noise. Be aware that blockchain functions are tagged as experimental and may ...
xtian777x's user avatar
  • 1,018
2 votes
Accepted

How to find the block number of a transaction in a Wolfram Blockchain?

Currently, BlockchainTransactionData doesn't return that information about the Wolfram blockchain. Note that blockchain functionalities are marked as experimental and that means they can change ...
xtian777x's user avatar
  • 1,018

Only top scored, non community-wiki answers of a minimum length are eligible