rippled
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 
26 namespace ripple {
27 
28 class RFC1751
29 {
30 public:
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 
47 private:
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
ripple::RFC1751::standard
static void standard(std::string &strWord)
Definition: RFC1751.cpp:352
std::string
STL class.
ripple::RFC1751
Definition: RFC1751.h:28
vector
ripple::RFC1751::btoe
static void btoe(std::string &strHuman, std::string const &strData)
Definition: RFC1751.cpp:293
ripple::RFC1751::etob
static int etob(std::string &strData, std::vector< std::string > vsHuman)
Definition: RFC1751.cpp:403
ripple::RFC1751::getKeyFromEnglish
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:450
ripple::RFC1751::insert
static void insert(char *s, int x, int start, int length)
Definition: RFC1751.cpp:315
ripple::RFC1751::extract
static unsigned long extract(char const *s, int start, int length)
Definition: RFC1751.cpp:266
ripple::RFC1751::getEnglishFromKey
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:483
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::RFC1751::wsrch
static int wsrch(std::string const &strWord, int iMin, int iMax)
Definition: RFC1751.cpp:369
ripple::RFC1751::s_dictionary
static char const * s_dictionary[]
Definition: RFC1751.h:61
ripple::RFC1751::getWordFromBlob
static std::string getWordFromBlob(void const *blob, size_t bytes)
Chooses a single dictionary word from the data.
Definition: RFC1751.cpp:494
string