Number Trick

General FreeBASIC programming questions.
Post Reply
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Number Trick

Post by deltarho[1859] »

I do home-brewed encryption for the fun of it, but for serious work I use AES.

How do you think "Vari_Cyph" will fare with a quantum computer? RSA and ECDSA are dead in the water when quantum computers mature. Not sure about AES128 but AES256 hasn't much to worry about. 'Pound for pound' AES128 is the better - AES256 could do with a few more rounds. If AES256 was 'upgraded' it would certainly have nothing to worry about.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

@deltarho[1859]

With "Vari_Cyph"

If you select a message size of 1 , then the message is 8 * 8 bits , or 64 bits..
If you select a garbage size of 1 then the garbage is 64 bits , it scramble 64 bits of message into 64 bits of garbage..
If you select a garbage size of 4 then the garbage is 64 x 4 bits , it scramble 64 bits of message into 256 bits of garbage.. so only 1 in 4 bits is data..

If you select a message size of 1 = 64 bits
If you select a garbage size of 128 then the garbage is 64 x 128 bits = 8192, it scrambles 64 bits of message into 8192 bits of garbage..
So only 1 in 128 bits is message, the rest is garbage.

If you select a message size of 1024 = 8192 bits of message..
If you select a garbage size of 128 , then it scrambles 8192 message bits into 1,048,576 bits of garbage...

The only way to crack the cypher , is to know what the randomly selected garbage bits are for each set...And the order of the 16 output chrs...

As you scramble the message bits into the garbage , some bits change and others don't...

But each set the message bits change and the garbage bits change....
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

With "Vari_Cyph"

You can set the values to x 1 message = 64 bits and garbage to 2 = 128 bits..

Then you can copy the output to the input , and change the values , and the key and output chrs..
And re-cypher it with a different set of values and different key...

You can re-cypher with different values and keys as many times as you want...

The worlds fastest and most AI complex, computers , could never de-cypher it...

To crack it , you'd need to figure out the message size , and garbage size , and what garbage bits were generated at each block.. and then figure the correct order for the 16 output chrs..

If it's cypher multiple times , forget it, it's impossible to crack...
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Number Trick

Post by deltarho[1859] »

The graveyard is full of methods which could not be cracked by their authors. The only method that I know of for certain cannot be cracked is a one-time pad which uses a key at least as long as the plaintext so not very useful for long messages. Your method does not seem very useful for long messages either.
then it scrambles 8192 message bits into 1,048,576 bits of garbage...
So with 2GB of sensitive health data would use 256GB of garbage. I cannot see people queueing up to use that method. I should not think that it would be particularly fast either.
The worlds fastest and most AI complex, computers , could never de-cypher it...
can also be said of AES128.

Once the NIST recommended passwords should have an entropy of at least 80 bits - they now recommend 112 bits. I use at least 22 random alpha-numeric characters which gives 131 bits of entropy and cannot be brute-forced, at the moment. Some websites come back with 'Not complex enough'. What do they know? You cannot get more complex than 8 bits in a byte and most of them won't allow that. If they looked at the length they would not have a case.

So, why use AES256? Well, that is for a Top Secret classification. Some people think that Top Secret means more secret than secret. There is no such thing as more secret than secret - secret is secret. If something needs to be kept secret for a short time, like a couple of years, then AES128 is good enough. However, if we are looking at something which needs to be secret in 15 years time, say, then we should use AES256. Top Secret then is more to do with the life expectancy of the secret than it is on the security level needed today. Software vendors talking about AES256 being 'military grade encryption' are on a PR trip. Battlefield secrets may only last for a few months, at most, and not 15 years.

AES is what we should use. A few more rounds with AES256 would be helpful and, as with DES, we could use triple-AES; although I shouldn't think that anyone is thinking along those lines - not for a long time.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

Another number trick, i just came up with...

Code: Select all


90
-9 
---
81
-81
--- 
0 <-- diff = 9 - 9 * 9

================

80
-8
---
72
-64
----
8 <-- diff = 9 - 8  * 8

================

70
-7
---
63
-49
-----
14 <-- diff = 9 - 7 * 7

================

60
-6
----
54
-36
-----
18 <-- diff = 9 - 6 * 6

================

50
-5
----
45
-25
-----
20 <-- diff = 9 - 5 * 5

================

40
-4
----
36
-16
-----
20 <-- diff = 9 - 4 * 4

================

30
-3
----
27
-9
-----
18 <-- diff = 9 - 3 * 3

================

20
-2
----
18
-4
-----
14 <-- diff = 9 - 2 * 2

================

10
-1
----
9
-1
-----
8 <-- diff = 9 - 1 * 1

It works with single digit squares... add , sub and a single digit mul..

Now to play with 2 digit numbers... to see if i can figure out a working formula that works on all numbers..
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Number Trick

Post by deltarho[1859] »

What we have is

n/10*(9 - n/10) for n = 90, 80, 70, ..., 10

The point of the exercise being what?
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

I'm working on a way to square large numbers.... With only shifts , adds , subtracts , and maybe a single or double digit multply..

14 x 14 = 196

1040 ( 1 x 10 ) added to ( 4 x 10 )
0104
------
0936

9 - 1 = 8 , ( 8 x 1 ) = 8
9 - 4 = 5 , ( 5 x 4 ) = 20
tot = 820

0936
-820
------
116 <-- were off ( under ) by 80 = ( 40 + 40 )
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

13 x 13 = 169

1030 ( 1 x 10 ) added to ( 3 x 10 )
-103
------
927

9 - 1 = 8 , ( 8 x 1 ) = 8
9 - 3 = 6 , ( 6 x 3 ) = 18
tot = 818

0927
-818
-------
109 <-- were off ( under ) by 60 ( 30 + 30 )
Last edited by albert on Aug 31, 2020 18:52, edited 1 time in total.
deltarho[1859]
Posts: 4305
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Number Trick

Post by deltarho[1859] »

albert wrote:I'm working on a way to square large numbers....
OK. I am out of this thread now. I wrote earlier: "I am sorry albert but I cannot get excited about squaring huge numbers"
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

18 x 18 = 324

1080 ( 1 x 10 ) added to ( 8 x 10 )
-108
------
972

9 - 1 = 8 , ( 8 x 1 ) = 8
9 - 8 = 1 , ( 8 x 1 ) = 8
tot = 808

0972
-808
-------
164 <-- were off ( under ) by 160 ( 80 + 80 )
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

10 x 10 = 100

1000 ( 1 x 10 ) added to ( 0 x 10 )
-100
------
900

9 - 1 = 8 , ( 8 x 1 ) = 8
9 - 0 = 9 , ( 9 x 0 ) = 0
tot = 800

0900
-800
-------
100 <-- were off ( under ) by 00 ( 00 + 00 )
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

Got the 1's and 10's done...

Now to work on 20's to 90's , then on to 3 digit numbers..
Stonemonkey
Posts: 649
Joined: Jun 09, 2005 0:08

Re: Number Trick

Post by Stonemonkey »

@Albert, 16 bit squares, there'll be other ways too.

Code: Select all

dim as ulong v=12345

print v*v

dim as ulong t=v,square

while v>0
    square+=t and - (v and 1)
    v shr=1
    t shl=1
wend

print square
sleep
end
or

Code: Select all

dim as ulong square,v=12345

print v*v

for i as long=0 to 15
    square+=(v shl i) and - ((v shr i) and 1)
next

print square
sleep
end
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Number Trick

Post by albert »

I got it working with 2 and 3 digit numbers..

123 x 123 = 15129

010409 <-- square each digit and make them all 2 digits

23 x 100 x 2 = 4600
20 x 3 x 2 = 120

4600 + 120 = 4720

010409
---4720 <-- add 4720
-----------
015129 <-- correct answer

Another:

246 x 246 = 60516

041636 <-- square each digit and make them all 2 digits

46 x 200 x 2 = 18400
40 x 6 x 2 = 480

18400 + 480 = 18880

041636
-18880 <-- add 18880
----------
060516 <-- correct answer

The problem is you have to cross multiply and double , so with longer numbers there would be a lot of cascaded adding....

I'm working on a faster way to arrive at the adder.. instead of cross mul and double..

With 3 digits there's 2 cross muls...
with 4 digits there would be 3 cross muls
etc..
Stonemonkey
Posts: 649
Joined: Jun 09, 2005 0:08

Re: Number Trick

Post by Stonemonkey »

You're also having to square each digit.

With 3 digits it can be done with just

123*123

1*12300+
2*1230+
3*123

=15129

But in that you have

1*12300=(1*1*10000+1*2*1000+1*3*100)
2*1230=(2*1*1000+2*2*100+2*3*10)
3*123=(3*1*100+3*2*10+3*3)

Where for part of that you have each digit squared and shifted, which gives you

1²*10000+2²*100+3²
+
(1*2+2*1)*1000
+
(1*3+3*1)*100
+
(2*3+3*2)*10
Post Reply