| Welcome to Crypto. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Base Translations Ciphers; Using Multiple Bases for Encryption | |
|---|---|
| Tweet Topic Started: Jan 18 2014, 04:53 AM (3,380 Views) | |
| jdege | Feb 24 2014, 04:49 PM Post #76 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Current practice, in software engineering, is to instrument code as it's being written. That is, for every piece of code, every method and class, as you write it, you write tests that exercise it. http://en.wikipedia.org/wiki/Unit_testing Whenever you write code, you do some sort of unit testing to ensure it works. You'll write some scaffolding code to surround it, so you can run it by itself, without having the rest of the application (that you haven't written yet) in place, or you write some stub code for the parts your code will call, but that you haven't written yet, What's been becoming more and more common, over the last 15-20 years, is to use a unit testing framework, which serves as the scaffolding, and a mocking framework, which makes it easy to implement the stubs, in a way that allows you to keep this test code around, so it can be run repeatedly, and frequently, over the lifetime of the code. So, suppose I'm looking at a Vigenere application. It takes a keyword, and from it generate a keystream. It reads a file, converts the characters into plaintext characters, adds the result to the keystream, and writes the result to a file. Ten years ago, in a well-designed application, I'd have expected to see a class for the cipher alphabet, that supported mod-26 addition and subtraction. I'd have expected a class that could read a text file and return a stream of cipher alphabet characters, and could take a stream of cipher alphabet characters and write a text file. I'd have a class that could take a keyword and generate a stream of cipher alphabet characters, and a method somewhere that could take two streams of cipher alphabet characters and add them together, or subtract them from each other. Today, I'd expect exactly the same, except that I'd also expect a set of unit tests for each of these classes, that pass when the methods do what they should and fail when they do not. These tests don't only confirm that the code works as it is intended to, and allows us to ensure that it still works as it was intended to, after we make modifications, it serves to document how the classes are intended to be used. One simple example - when you're adding in a cipher alphabet, mod-26, is 'A' treated as 0, or as 1? If I have a unit test that contains "Assert.AreEqual(CipherChar('A'), CipherChar('A')+CipherChar('A'));", I know that it is the former. And I know that if I modify the CipherChar class in such a way as to violate that assumption, I will find out about it quickly. |
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| novice | Feb 24 2014, 07:37 PM Post #77 |
|
Super member
![]() ![]() ![]() ![]() ![]() ![]()
|
@jdege Thank you very much for an excellent teach-in. I had not realised that such techniques are in use. In my amateurish approach, my checking routine for cipher solving programs has been just to put in a cipher text and the correct key to check whether the correct plaintext comes out together with a reasonable score. Bugs do get through this process and catch up with me later -- usually proving rather hard to find. I like the modular approach of testing each step of the program as it's written. It's going to take some thinking out and some extra work but I guess once the unit tests are written they can be used over and over again. |
![]() |
|
| jdege | Feb 24 2014, 08:02 PM Post #78 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
The most complete expression of this method is called "Test-Driven Development". The process is:
With practice, this is actually faster than writing code the more usual way of flailing around aimlessly. But it's premised on a couple of constructs, and getting an understanding of all of them simultaneously can be a big chunk to absorb. To take full advantage of this, you need to structure your code to make tests for each module easy. This means making the dependencies between modules explicit, so that you can replace them with mocks or stubs. The best intro to this I've seen: http://www.youtube.com/watch?v=5lIeky2V4dc Edited by jdege, Feb 25 2014, 06:40 AM.
|
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| WTShaw | Feb 25 2014, 11:49 AM Post #79 |
|
Advanced Member
![]() ![]() ![]() ![]() ![]()
|
I'm going to give several different comments here, succinctly(?): @novice...Thanks for confirming in #73 that the program referenced work on your Safari, to be expected. Whether or not it is up to some universal standard is open subject to specific circumstance that might be different. Yes, the semi-automatic GUI idea makes sense as it also encourages the user to understand a few basics of what is really happening in the process. @jdege...As many of these programs developed, I tried different approaches but the thrust is that I like building around modular designs and testing which allows with occasional minor alterations to paste-up completely new algorithms quickly...There are SO many possibilities that at almost any point many children can be spawned. So, it was relatively quickly to extend the current focus to two more which I need to put up on crypto.javascript: 1) Daqqaq*SimpleSCPome26.html 2) Daqqaq*SimpleSCPome36.html Taking the same simplified Pt27, the translation are to Ct13, then a Selected Character routine is optional in which each character in Ct, positions 0-12, is paired with another in positions 13-25, and using my overkill character generator, maybe half of the Ct char are switched to a higher value. At the other end of the trail in order to recover original text, if a higher acceptable value in sensed in Ct, it is converted back to the lower position option. This is true even if the set is deranged in the last function. With the 36 character set for Ct, the positions 0-12 and 13-25 used while with the stream function all positions are used. @mok-kong shen...My usual modules are LittleEndian since the programming is easier that way. To get the shortstop integer values would require major reconstruction of the functions which can, might, and has stressed the language used for unknown reasons, gone too near the limits of capabilities I suppose, so I avoid such. I started out doing everything the hard and messy way, so I changed my directions by necessity. Starting out was full of many such compromises, and I will not be surprised if there are even more ahead... |
![]() |
|
| mok-kong shen | Feb 25 2014, 07:07 PM Post #80 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
@WTShaw: If I understand your comment correctly, that explains the issue concerning novice's recent post, i.e. it doesn't put the correctness of my code NUMCODING into question. BTW, if you do have any concrete critques to my code or find deficiencies in its practical applications, please kindly tell them to me as soon as you could manage such that I could attempt to improve the code soon. Thanks in advance. |
![]() |
|
| jdege | Feb 25 2014, 08:21 PM Post #81 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
The goal in programming has been, from the very early days, to build a system out of components such that the components can be combined in differing combinations to build new functionality more easily than starting from scratch. And it's a goal that has proven maddingly elusive, over the years. |
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| novice | Feb 25 2014, 08:33 PM Post #82 |
|
Super member
![]() ![]() ![]() ![]() ![]() ![]()
|
I suppose I do flail around quite a bit but it's usually with some aim in sight!
I had a look at this but personally didn't find it easy.
That makes every sense. I have rewritten some code along these lines today, and included tests, and am very happy with the results. A definite step forward. |
![]() |
|
| jdege | Feb 25 2014, 09:11 PM Post #83 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
That's what I meant, when I said that it's a lot to absorb all at once. And it's more than I have time to explain, right now. I may give it a shot, later this evening. |
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| novice | Feb 25 2014, 09:57 PM Post #84 |
|
Super member
![]() ![]() ![]() ![]() ![]() ![]()
|
That would be good. |
![]() |
|
| jdege | Feb 26 2014, 01:02 PM Post #85 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I've given it a start: Vague ramblings on Unit Test frameworks, Mocking frameworks, and Inversion of Control containers |
| When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. | |
![]() |
|
| WTShaw | Mar 3 2014, 04:27 AM Post #86 |
|
Advanced Member
![]() ![]() ![]() ![]() ![]()
|
Questions arise as to what group sizes and bases might be best chosen for base translations. I suppose I missed a very few calculations but I often refer to a list of numbers for various bases to useful powers in this list: http://cryptopopcorn.com/Crypto/docs/BasePowers.txt For example: 27x13 Daqqaq-Pome26...Pt Base 27(7 char) <98.6%> Ct Base 13(9 char) 10460353203 = 3 ^ 21 10604499373 = 13 ^ 9 Lucky13 Disregard the Lucky 13 note but consider that 3^21=27^7 as needed in Daqqaq, plus 13^9 Perhaps the lazy way to find prospective algorithm base relationships, it has helped me greatly. Picking just any numbers for bases and groups might provide a leak to actual group sizes and hints to which bases are involved. The idea is to work toward a flat distribution of Ct characters across all the Ct. Even as Pt characters are not externally seen, some few usual Ct sets might confuse an attacker...on purpose. A stream cipher chaser can assist in elimination of std Pt character distributions, now not so golden at all. |
![]() |
|
| mok-kong shen | Mar 3 2014, 11:16 AM Post #87 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
In the present context it seems evident that it suffices to choose 2 arbitrary unknown to the opponent alphabet sizes (the plaintext alphabet size has a lower bound determined by the given plaintext) that are convenient/reasonable and scramble them well, excepting that for the plaintext alphabet one has to observe a constraint concerning its first character that I repeatedly mentioned earlier. |
![]() |
|
| WTShaw | Mar 4 2014, 01:32 PM Post #88 |
|
Advanced Member
![]() ![]() ![]() ![]() ![]()
|
Is that a requirement of python because it certainly isn't of the languages I use. In practice, I consider such requirement neither convenient nor reasonable. Requiring a base permutation in general to start with a specific character in effect excludes many possible permutations of the set and weakens the key. If a language needs to enclose a permutation within a pair of single or of double quotation marks, the way around that so that they could themselves be part of the permutation would be to use BOTH as in setx = "egthujki'ie" + 'abdcbnm"zxy' that works in javascript for higher bases but not for lower ones..strange. Also strange but as a holdover from C, the "\" character must be "\\" to be recognized, or use a character code as a constant. |
![]() |
|
| mok-kong shen | Mar 4 2014, 02:00 PM Post #89 |
|
NSA worthy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Did you read my earlier post #57 or had forgotten it? As long as computation is done like there (which is not "little-endian" but which you also used in Post#52 -- since I have verified your computation in Post#52 at the end of my Post#57) that is a requirement stemming from math and has entirely nothing to do with progrmming language limitations. Edited by mok-kong shen, Mar 4 2014, 06:28 PM.
|
![]() |
|
| WTShaw | Mar 9 2014, 05:28 AM Post #90 |
|
Advanced Member
![]() ![]() ![]() ![]() ![]()
|
You are using two group sizes. You must choose one or the other, or simply follow the design of the algorithm. Your choice of group size determines whether the leading zeros, if any, are assigned the zero place character from the present character set permutation. Here is something that might be of interest, relative to Base Translation Algorithms: https://groups.google.com/forum/#!topic/cryptojavascript/f-hTC6sztxw |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| Go to Next Page | |
| « Previous Topic · General · Next Topic » |





![]](http://z2.ifrm.com/static/1/pip_r.png)



7:27 PM Jul 11