bignum

SHA256 Hash results different across Android & iOS for Big numbers

怎甘沉沦 提交于 2019-12-03 03:23:39
I'm trying to Hash a BigInteger/BigNum and I'm getting different results in Android/iOS. I need to get the same Hash result so that both the apps work as per the SRP protocol. On closer inspection it is working fine for positive numbers but not working for negative numbers (first nibble greater than 7). Not sure which one is correct and which one is to be adjusted to match with the other. Android: void hashBigInteger(String s) { try { BigInteger a = new BigInteger(s, 16); MessageDigest sha = MessageDigest.getInstance("SHA-256"); byte[] b = a.toByteArray(); sha.update(b, 0, b.length); byte[]

Raising large number to large power and mod it by a large number?

强颜欢笑 提交于 2019-12-03 01:00:48
问题 I am stuck with probably simple question. I got 3 large numbers(A,B,C), all integers and i need to do the following: power A to B and modulo the result by C, and then check if the result is equal to 1. Here's my code: double power = fmod((pow((double)A,(double)B)),(double)C); if (power != 1){ printf("Something!\n"); } And it doesnt work(I tried small numbers, like 17 powered by 28 and moduled by 29). Any suggestions on that? 回答1: Try this (in order to avoid arithmetic overflow): unsigned long

Generating a pseudo-natural phrase from a big integer in a reversible way

戏子无情 提交于 2019-12-01 17:56:59
I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the original SHA1 hash from that phrase.) The phrase need not make sense. I would even settle for a whole

Generating a pseudo-natural phrase from a big integer in a reversible way

*爱你&永不变心* 提交于 2019-12-01 17:39:23
问题 I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the

bignum in emacs/elisp

时光总嘲笑我的痴心妄想 提交于 2019-12-01 16:27:34
Does emacs have support for big numbers that don't fit in integers? If it does, how do I use them? Török Gábor Emacs Lispers frustrated by Emacs’s lack of bignum handling: calc.el provides very good bignum capabilities.— EmacsWiki calc.el is part of the GNU Emacs distribution. See its source code for available functions. You can immediately start playing with it by typing M-x quick-calc . You may also want to check bigint.el package , that is a non-standard, lightweight implementation for handling bignums. 来源: https://stackoverflow.com/questions/1371638/bignum-in-emacs-elisp

bignum in emacs/elisp

ぃ、小莉子 提交于 2019-12-01 14:18:44
问题 Does emacs have support for big numbers that don't fit in integers? If it does, how do I use them? 回答1: Emacs Lispers frustrated by Emacs’s lack of bignum handling: calc.el provides very good bignum capabilities.— EmacsWiki calc.el is part of the GNU Emacs distribution. See its source code for available functions. You can immediately start playing with it by typing M-x quick-calc . You may also want to check bigint.el package, that is a non-standard, lightweight implementation for handling

Fast BigFloat unit for Delphi

孤者浪人 提交于 2019-12-01 06:40:36
问题 I'm looking for a fast BigFloat unit, which can deal with addition, subtraction, multiplication and division (log would be fine but isn't necessary) and which has a precision of at least 100 decimal places. I've tried this unit, but it's about 1,000 times slower than standard extended operations. So, does anyone know a fast(er) BigFloat unit for Delphi? Henry 回答1: To summarize the comments to the OP's question. A C library is probably the best solution for a big floating point library. GMP

How does GMP stores its integers, on an arbitrary number of bytes?

冷暖自知 提交于 2019-12-01 01:17:26
问题 2^64 is still far from the "infinity" my ram/hard drive can handle... First I wonder how GMP works with memory/processor since it does some kind of shady optimisations... I was also wondering if there is a way of storing an integer (unsigned, it's easier) on an arbitrary number of bytes. For example, on 50 bytes, I would have a cap of 2^400 -1. The thing to do is to work well with carries to keep the number consistent from one byte to another, I have some idea about that, but I'm really not