rippled
Loading...
Searching...
No Matches
RFC1751.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_CRYPTO_RFC1751_H_INCLUDED
21#define RIPPLE_CRYPTO_RFC1751_H_INCLUDED
22
23#include <string>
24#include <vector>
25
26namespace ripple {
27
29{
30public:
31 static int
32 getKeyFromEnglish(std::string& strKey, std::string const& strHuman);
33
34 static void
35 getEnglishFromKey(std::string& strHuman, std::string const& strKey);
36
44 static std::string
45 getWordFromBlob(void const* blob, size_t bytes);
46
47private:
48 static unsigned long
49 extract(char const* s, int start, int length);
50 static void
51 btoe(std::string& strHuman, std::string const& strData);
52 static void
53 insert(char* s, int x, int start, int length);
54 static void
55 standard(std::string& strWord);
56 static int
57 wsrch(std::string const& strWord, int iMin, int iMax);
58 static int
59 etob(std::string& strData, std::vector<std::string> vsHuman);
60
61 static char const* s_dictionary[];
62};
63
64} // namespace ripple
65
66#endif
static int wsrch(std::string const &strWord, int iMin, int iMax)
Definition: RFC1751.cpp:382
static int etob(std::string &strData, std::vector< std::string > vsHuman)
Definition: RFC1751.cpp:416
static void standard(std::string &strWord)
Definition: RFC1751.cpp:365
static char const * s_dictionary[]
Definition: RFC1751.h:61
static void btoe(std::string &strHuman, std::string const &strData)
Definition: RFC1751.cpp:304
static void getEnglishFromKey(std::string &strHuman, std::string const &strKey)
Convert to human from a 128 bit key in big-endian format.
Definition: RFC1751.cpp:496
static void insert(char *s, int x, int start, int length)
Definition: RFC1751.cpp:326
static unsigned long extract(char const *s, int start, int length)
Definition: RFC1751.cpp:275
static std::string getWordFromBlob(void const *blob, size_t bytes)
Chooses a single dictionary word from the data.
Definition: RFC1751.cpp:507
static int getKeyFromEnglish(std::string &strKey, std::string const &strHuman)
Convert words separated by spaces into a 128 bit key in big-endian format.
Definition: RFC1751.cpp:463
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26