Comments (2)
I used serialize advisedly, because JSON is utterly useless for binary strings unless you pre-encode them and secret tokens are fairly likely to contain such strings. Eventually it should be migrated to msgpack or some other less language-specific binary encoding. That's one reason for the encoding type prefix (that "p" there).
Though actually, I wouldn't mind trying to pre-flight a conversion to JSON ("j" prefix) and fall back to serialize only if the value contains non-UTF8 strings.
from lockbox.
We can use strategy pattern (https://github.com/alexmanno/DesignPatternsPHP/tree/master/Behavioral/Strategy)
For example:
interface SerializerInterface {
public function serialize();
public function unseiralize();
}
class PHPSerializer implements SerializerInterface { /* implementation */ }
class JsonSerializer implements SerializerInterface { /* implementation */ }
class Secret
{
// ....
public function __constructor(SerializerInterface $serializer, $value, $_import = null)
{
// ...
}
//...
}
from lockbox.
Related Issues (16)
- make hmac algo configurable HOT 1
- Automated Testing on PR HOT 3
- adopt psr-2 code style / formatting
- php version bump HOT 3
- libsodium support HOT 3
- Add test coverage for all crypto drivers
- polyfill for random_bytes HOT 2
- tag a version HOT 2
- abstract filesystem calls HOT 2
- Secure distribution of secrets (KeyDrop) HOT 1
- Fatal error: Uncaught Exception: Unknown algorithm HOT 7
- Raw encryption HOT 2
- separate key for hmac and encryption HOT 2
- PHPDoc HOT 3
- Use PhpUnit instead of custom test framework HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lockbox.