mirror of
https://github.com/Steffo99/unimore-oop-2020-cleaver.git
synced 2024-11-25 01:24:19 +00:00
So... the only thing that's left is to read the salt and iv
This commit is contained in:
parent
66fe4f733d
commit
5638d77990
22 changed files with 444 additions and 324 deletions
7
.idea/inspectionProfiles/profiles_settings.xml
Normal file
7
.idea/inspectionProfiles/profiles_settings.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
|
@ -1,3 +0,0 @@
|
|||
# Cleaver examples
|
||||
|
||||
- `loremipsum.txt`: 50 paragraphs of Lorem Ipsum generated from [lipsum.com](https://lipsum.com).
|
|
@ -1,101 +0,0 @@
|
|||
# From https://lipsum.com/
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi hendrerit vitae quam vel placerat. Donec aliquet sed dolor in imperdiet. Pellentesque lacinia dictum risus semper tincidunt. Donec non metus vitae augue dignissim venenatis vitae in erat. Pellentesque elementum interdum tellus eu finibus. Vivamus et justo in nisl cursus feugiat. Phasellus finibus fringilla tortor, et posuere nisi maximus id. Pellentesque a egestas magna, sit amet ullamcorper orci.
|
||||
|
||||
In a sagittis tortor, eu maximus felis. Duis pharetra orci ut pretium tempus. Maecenas sed pretium ante. Cras a dictum lectus. Praesent non leo dui. Suspendisse volutpat faucibus mi, quis congue lectus dapibus at. Nullam ipsum ligula, tempor sed nisl a, molestie vestibulum nunc. Donec pellentesque enim eget lorem lobortis feugiat. Etiam facilisis ante sit amet nunc euismod, eu tristique odio interdum. Quisque sodales semper dolor at pretium. Etiam at sapien tellus. Suspendisse potenti.
|
||||
|
||||
Praesent ultricies nunc blandit felis eleifend, non elementum mi luctus. Phasellus bibendum mauris vitae dapibus interdum. Phasellus dictum risus et efficitur cursus. Nullam sed finibus justo. Donec nec sapien pretium, laoreet diam a, convallis nunc. Aliquam non ante tortor. Maecenas viverra ligula tempor maximus lobortis.
|
||||
|
||||
Quisque sodales congue finibus. Ut augue dolor, molestie sodales quam at, placerat varius neque. Mauris et tincidunt magna, eget posuere justo. Aenean euismod arcu in quam imperdiet mattis. Pellentesque pharetra erat vitae est accumsan, ac placerat ligula lacinia. Maecenas diam nisl, dictum eget sollicitudin at, consectetur vitae nisi. Pellentesque sollicitudin, urna ac hendrerit pellentesque, nibh ipsum tristique risus, ut venenatis enim dui a ex. Etiam bibendum mollis tellus vitae venenatis. Nunc scelerisque eros sed dolor tempus mattis.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque id risus quis est sollicitudin aliquam at non diam. Aenean viverra vel odio ac blandit. Cras leo enim, iaculis in faucibus eget, dictum vel dolor. Fusce vel nisl laoreet sapien tempor pellentesque. Fusce a lorem ut ante finibus feugiat. Mauris vehicula, nulla vitae posuere venenatis, erat lectus tempor odio, in dignissim dolor nisl ut nunc. Vivamus tristique dignissim neque. Nulla fringilla sed lectus vitae placerat. Donec vitae nulla imperdiet, venenatis purus vel, elementum odio.
|
||||
|
||||
Fusce et imperdiet nisi. Praesent molestie enim orci, ut feugiat tellus facilisis a. Donec vitae turpis ultricies, vestibulum ipsum non, tempus massa. Nam accumsan lobortis ante, vitae porttitor turpis cursus eu. Suspendisse potenti. Mauris rutrum auctor augue, nec faucibus ipsum vestibulum id. Proin vehicula condimentum sem. Donec at ultrices orci. Sed bibendum nibh vel mi euismod, ut sodales ex pretium. Nunc sit amet semper orci, id blandit ligula. Aenean interdum, mi eget tincidunt imperdiet, mauris est euismod elit, sollicitudin sodales nisi nulla sed ante.
|
||||
|
||||
Phasellus at iaculis lorem. Vivamus eget bibendum diam. Sed eget leo vel orci ornare pharetra quis in odio. Mauris nulla elit, posuere vitae dolor sit amet, laoreet pulvinar metus. Integer magna lacus, ornare finibus pharetra ut, tempor non neque. Cras molestie tempor enim et auctor. Pellentesque eget vestibulum urna, ut porttitor sem. Etiam gravida nisl lectus. Suspendisse potenti. Ut maximus ullamcorper mi, et eleifend ante tempus et. Nunc leo sem, malesuada vel sapien sed, ornare ornare metus. Nulla vitae ante eget velit venenatis sodales a dapibus ipsum. Phasellus justo lectus, maximus sit amet tempus eget, tempus ac velit. Phasellus nec pellentesque massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst.
|
||||
|
||||
Proin ultricies, ante eu finibus consectetur, eros urna aliquam libero, nec placerat purus mi et dolor. Cras laoreet id tortor sit amet tincidunt. Proin varius viverra ultrices. Aenean vitae turpis vitae erat porttitor pellentesque. Proin in ante non velit mollis iaculis. Phasellus dignissim vel metus finibus vulputate. Curabitur varius est eget nisi ultricies, vitae suscipit lectus venenatis. Vestibulum feugiat libero ac urna feugiat rhoncus. Morbi tempus tincidunt tempor. Suspendisse lobortis metus eget scelerisque commodo. Integer velit orci, tristique id arcu sed, scelerisque imperdiet purus. Duis rhoncus augue id sapien rutrum sollicitudin. Mauris scelerisque nibh a enim vestibulum, id fringilla nulla pellentesque. Phasellus euismod sapien vulputate nisl aliquet, sodales feugiat lectus efficitur. Mauris egestas cursus odio sit amet tincidunt.
|
||||
|
||||
Maecenas lacinia orci mauris, sed pretium ante eleifend dignissim. Suspendisse feugiat vel enim eget tincidunt. Sed consectetur, orci eu condimentum ornare, leo lacus convallis nisl, semper volutpat eros orci non enim. Curabitur a dapibus lorem. In et bibendum neque. Mauris eget vestibulum diam. Suspendisse lacinia nulla vel efficitur faucibus. Quisque id tristique lectus, tincidunt egestas ex. Nullam feugiat, lorem a sollicitudin varius, eros quam dignissim nulla, in sodales nisl dolor non erat. Nullam interdum ultricies mi, quis dapibus orci scelerisque id.
|
||||
|
||||
Quisque vestibulum ipsum sed purus maximus volutpat. In id hendrerit ex. Praesent vestibulum nibh augue, dignissim egestas nisl placerat vehicula. Etiam eu sollicitudin eros, a condimentum mauris. Ut fringilla sapien ac suscipit rhoncus. Fusce ex ligula, convallis a pulvinar vel, varius ut lectus. Nam vehicula in quam eu ornare. Integer eget nulla turpis. In consequat fringilla magna eu tempus. Nam ut urna nisl.
|
||||
|
||||
Quisque consequat nisl sit amet velit pharetra, at bibendum ipsum dapibus. Vivamus euismod nisl dolor, quis ultricies orci elementum ac. Vestibulum interdum porta turpis, sed pulvinar arcu dapibus a. Sed cursus ultrices aliquam. Mauris venenatis dolor id urna egestas, id faucibus justo scelerisque. Donec lobortis sollicitudin tellus. Mauris quis dolor hendrerit, interdum tellus quis, mattis diam. Vivamus molestie ligula a fermentum consectetur. Donec ut euismod eros, ut efficitur diam. Morbi tortor metus, accumsan non gravida vel, consectetur vel velit. Suspendisse in quam congue, commodo est vitae, elementum turpis. Vestibulum nunc tellus, faucibus ac scelerisque at, maximus eu quam. Vivamus tincidunt non erat tempus laoreet.
|
||||
|
||||
Pellentesque sit amet nibh mauris. Nulla venenatis massa at vestibulum auctor. Nulla quis lectus quis nunc aliquam rhoncus vel a nulla. Aenean sagittis placerat imperdiet. Phasellus arcu mi, vehicula eu dui ac, volutpat mattis ipsum. In eu eros a dui tristique posuere. Ut non eros egestas, facilisis felis sagittis, semper erat. Proin ut commodo nibh. Etiam quis scelerisque felis. Suspendisse viverra imperdiet augue ac auctor. Aenean ultrices lorem eu diam tincidunt, eget egestas metus auctor. Proin a nisi cursus, iaculis dolor quis, aliquet magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent lacinia eros id ex pulvinar, at ultrices diam rutrum. In facilisis sodales massa vitae sodales.
|
||||
|
||||
Suspendisse consequat libero purus, ac tincidunt lectus porta non. Proin mattis diam ac pulvinar aliquet. Nunc finibus elit in sem porttitor, ac sodales turpis sodales. Morbi et rhoncus erat. Etiam vestibulum consequat velit, quis hendrerit mauris tincidunt sit amet. Sed cursus nisi non porta malesuada. Proin a feugiat massa. Integer rutrum consectetur congue. Fusce ut auctor mauris. Mauris et tortor fermentum, maximus nunc vel, suscipit risus. Vivamus pharetra ligula at odio tempor tincidunt. Sed elementum justo arcu, et tempor risus tincidunt nec. Cras ac blandit massa, sit amet auctor tortor. Sed accumsan nibh urna, vel pretium justo congue ac. Nulla id augue velit.
|
||||
|
||||
Donec rhoncus interdum tortor id scelerisque. Aenean gravida odio at sem placerat, eu placerat risus sollicitudin. Integer iaculis, diam quis lacinia maximus, libero arcu commodo turpis, at porta elit sapien non erat. Duis at pharetra sapien, eu tincidunt nibh. In hac habitasse platea dictumst. Quisque lacinia risus et sem mollis, vitae imperdiet orci tincidunt. Aenean tempus felis lectus, eget malesuada purus bibendum ac. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
|
||||
|
||||
Nunc sit amet tellus ornare, cursus odio id, suscipit dui. Proin condimentum sem erat, in sodales sem cursus hendrerit. Nullam eu venenatis justo, vel rhoncus felis. Quisque in porttitor libero, quis viverra nunc. Cras tempus felis sem, vel pulvinar velit gravida sed. Integer consectetur mi quis arcu tempus mattis. Nunc metus quam, rutrum at porta vitae, sollicitudin vitae leo. Sed et aliquet sem. In luctus, lacus eget euismod viverra, sapien libero accumsan turpis, in porttitor purus sapien non ex. Aliquam eget neque ligula. Duis porttitor ipsum vel magna vestibulum, ut sollicitudin ex semper. Nullam iaculis scelerisque massa, at malesuada enim fermentum quis.
|
||||
|
||||
Morbi fermentum faucibus mi et cursus. In feugiat elementum rhoncus. In ut gravida dui, eu pulvinar est. Suspendisse sed euismod tortor, in tempus sem. Donec luctus quam mattis mi consectetur congue. Aenean tellus nisi, gravida sed augue ac, vestibulum venenatis mauris. Etiam venenatis sollicitudin enim eget consectetur. Sed a porttitor libero. Duis quis nulla a magna eleifend egestas. Nunc faucibus ligula ut egestas venenatis. Vivamus gravida sem diam, et ultricies quam suscipit semper. Quisque risus urna, fringilla at mauris nec, ullamcorper interdum arcu. Pellentesque id dolor sed massa fermentum laoreet. Pellentesque posuere enim sit amet nulla pretium dignissim vel ac purus. Cras accumsan eleifend nisl, eu dignissim purus ultricies sit amet.
|
||||
|
||||
Ut laoreet augue porta vulputate sollicitudin. Vestibulum sagittis, erat vel dignissim interdum, diam ante varius erat, sed ultricies orci ligula sed felis. Nullam congue lacus dui, cursus maximus arcu fringilla in. Vivamus pellentesque diam sed libero consequat, non viverra lorem fermentum. Nam ac libero eros. Aliquam sodales ligula libero, ac sodales sem aliquam vitae. Donec non auctor est. Suspendisse rhoncus nisi in aliquet sollicitudin. Donec consectetur viverra lacus, nec vehicula odio pulvinar sed.
|
||||
|
||||
Donec eu ultricies arcu. Sed quis justo nulla. Donec luctus tellus in dolor pellentesque accumsan. Duis eget dui nec nisl aliquam ullamcorper non eget ipsum. Phasellus nec vehicula ex. Sed metus orci, fermentum vel enim et, rhoncus fermentum diam. Integer sollicitudin tincidunt neque, in viverra enim posuere vel. Sed in quam nec mi tristique tincidunt. Cras volutpat sem blandit erat interdum, vitae dapibus velit semper. Phasellus vulputate massa ipsum, vel vulputate nibh facilisis ut. Nulla facilisi.
|
||||
|
||||
Curabitur a erat et lorem ultricies lacinia at sed leo. Pellentesque non consectetur augue. Nulla sem risus, laoreet sed purus sed, sodales rutrum magna. Curabitur orci orci, tincidunt vel magna tristique, aliquet commodo libero. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut nisl velit, pharetra non est molestie, facilisis mollis mi. Nunc vel tellus ac est vulputate interdum. Quisque molestie enim ac massa tincidunt, et commodo lacus venenatis. Curabitur interdum est neque, non porta orci scelerisque sit amet. Vestibulum consequat risus vitae commodo dignissim. Aenean sed purus pellentesque, pretium ex vel, pulvinar purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse sed congue libero, vitae mollis est. Nullam ultricies lobortis urna ut malesuada.
|
||||
|
||||
Pellentesque euismod dignissim mauris ut hendrerit. Cras gravida mi id nulla dictum, sit amet eleifend nisi commodo. Duis aliquam diam felis. Nam facilisis, diam sed vestibulum ornare, lorem nisi dictum ex, at finibus dui tellus ac est. Ut mattis consectetur sodales. Integer ultrices pellentesque turpis ac iaculis. Sed mattis tellus ut suscipit iaculis. Nunc semper mattis interdum. Curabitur ultrices mollis lacus, tempor imperdiet velit dictum vitae. Nam scelerisque dui eu felis pellentesque consectetur. Nullam molestie vestibulum erat elementum placerat. Quisque neque mi, vehicula in fermentum sit amet, malesuada vel diam.
|
||||
|
||||
Aenean eget faucibus erat. Proin cursus libero ut dictum tempus. Nunc ullamcorper hendrerit ligula in hendrerit. Morbi dapibus lacus et rhoncus congue. Sed at iaculis eros. Aliquam posuere eleifend accumsan. Aenean varius aliquam nulla nec sodales. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla porta ligula ac nunc finibus efficitur. Sed leo mauris, pellentesque nec justo nec, mattis interdum velit. Nulla at velit dolor. Mauris nec dictum eros, sed tincidunt massa. Praesent varius nibh vel nunc ullamcorper, sed facilisis nisl consectetur. Nullam orci magna, iaculis in tincidunt at, congue non leo. Vivamus bibendum non neque a lobortis. Donec molestie nisl nunc, sit amet tristique elit accumsan quis.
|
||||
|
||||
Praesent scelerisque commodo turpis, vitae ultricies odio. Curabitur ut accumsan nisi. Nullam odio mauris, pharetra sed est nec, vestibulum volutpat felis. Quisque non nibh libero. Curabitur quis tellus sit amet elit gravida blandit quis sed ex. Etiam tempor dictum lorem quis finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam placerat tortor quam, id consequat enim semper vitae. Praesent in elit quis mauris bibendum euismod a a risus. Integer in risus vitae nibh commodo convallis. Integer feugiat orci ipsum, sit amet dictum enim finibus eu. Donec malesuada sapien a feugiat vehicula. Proin imperdiet augue a mi malesuada mattis. Quisque nec nunc sit amet risus hendrerit convallis.
|
||||
|
||||
Proin tincidunt dui vitae mi dictum scelerisque. Donec sollicitudin neque ligula, venenatis hendrerit risus volutpat porta. Nulla venenatis nulla tortor, ac ultricies risus venenatis sit amet. Fusce a ultricies dui. Morbi fermentum sem orci, a pharetra nibh fringilla ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam arcu augue, scelerisque nec ipsum a, malesuada efficitur nulla. Mauris a nisi et dolor faucibus tristique id sit amet enim. Aliquam vitae ultricies velit. Sed venenatis tristique magna ac commodo. Donec eu maximus urna, at pellentesque risus. Nullam commodo velit id posuere condimentum. Aliquam vitae molestie metus, nec commodo tellus.
|
||||
|
||||
Donec sit amet dolor malesuada, molestie mauris vitae, hendrerit mauris. Suspendisse potenti. Maecenas ullamcorper congue quam ac gravida. Integer auctor euismod auctor. Donec blandit turpis sit amet finibus suscipit. Vivamus consequat a eros in pulvinar. Proin risus lacus, rhoncus eu ligula at, elementum hendrerit neque. Quisque sagittis hendrerit condimentum. Etiam maximus libero auctor, vehicula tellus vel, auctor urna. Praesent eu diam tempus, porttitor magna ac, elementum neque.
|
||||
|
||||
Maecenas blandit molestie nulla, eget finibus risus lobortis at. Ut orci ligula, porta mollis quam a, tincidunt accumsan massa. Quisque gravida leo vitae tortor accumsan, non tempor sem dictum. Donec aliquet nec lorem sed dapibus. Vestibulum tincidunt luctus ante, eget aliquam velit viverra vel. Pellentesque a ornare massa. Quisque condimentum risus quis odio pharetra, in malesuada metus pulvinar. Pellentesque eros sapien, pellentesque vel eleifend non, dictum a enim. Pellentesque vitae pretium augue. Nulla id ultricies neque. Sed sed luctus neque. Curabitur ut justo nec leo varius consequat.
|
||||
|
||||
Quisque blandit, sem sit amet vehicula dignissim, quam tellus sollicitudin tortor, a sagittis augue elit at sapien. Ut convallis aliquet egestas. Nam iaculis massa nec nisl varius, ac lobortis purus elementum. Cras finibus dictum dolor eu eleifend. Integer mattis, urna at congue interdum, tortor purus cursus tortor, sed placerat turpis turpis eu sapien. Mauris at felis interdum, euismod lorem porttitor, malesuada urna. Duis accumsan eleifend semper. Ut eros ante, iaculis vel ante maximus, ullamcorper sagittis urna. Nunc ut orci nec ante cursus mattis. Morbi nec rhoncus ligula. In ac libero pellentesque, porttitor odio sed, tempus enim. Sed quis nunc nec dui bibendum cursus vel et justo. In ultrices augue ut odio luctus, nec commodo tortor posuere.
|
||||
|
||||
Vestibulum ac pellentesque enim, at pharetra magna. Cras facilisis nunc vitae magna auctor tempor. Vivamus fringilla sodales lobortis. Donec consequat, lacus sed laoreet iaculis, justo mauris tincidunt dolor, quis mollis nisl velit mattis mauris. Maecenas bibendum vehicula volutpat. Proin a arcu pulvinar, venenatis massa vitae, porta ante. Nunc consectetur ornare semper. Fusce egestas diam laoreet nunc mollis gravida. Mauris fermentum ipsum et diam aliquam, sagittis suscipit ante iaculis.
|
||||
|
||||
Nullam non ullamcorper elit. Sed fringilla nisi in nunc lobortis, ac laoreet turpis tempor. Curabitur sit amet consectetur lectus. Donec cursus quis libero nec pulvinar. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris tincidunt eleifend eros, eget cursus nisi finibus eget. Sed ut fermentum orci, fermentum rhoncus dui. Sed tempus neque et laoreet vulputate. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus quis condimentum lacus, ac tempor lorem. Suspendisse viverra justo eget justo aliquam tristique. Cras laoreet urna sem, nec tempus sem rhoncus eu. Sed sit amet feugiat nunc.
|
||||
|
||||
Nullam sem felis, ornare sagittis sapien vel, sagittis auctor est. Curabitur eu rutrum ante, eget tincidunt elit. Morbi mauris sem, auctor quis blandit vel, lobortis ut leo. Ut ac nulla ut nisi gravida tempor ac ut velit. Phasellus ultrices ex ac erat pellentesque, ut aliquam risus sollicitudin. Donec accumsan metus at pulvinar suscipit. Duis sollicitudin ac lorem et efficitur. Curabitur rhoncus id est sit amet hendrerit. Nam arcu diam, vestibulum a sem tempus, euismod condimentum lacus. Proin fringilla lacus ac ipsum egestas ultrices. Duis vestibulum porta semper. Curabitur dapibus metus vitae enim vulputate, eget facilisis tellus varius. Maecenas quis blandit enim, et tempor nunc. Praesent tincidunt mi ac nunc hendrerit commodo. Integer eget molestie nunc.
|
||||
|
||||
Morbi massa nibh, pulvinar et ullamcorper iaculis, volutpat ut tortor. Nunc iaculis laoreet lectus eget bibendum. Integer sed felis sagittis, porta velit in, dignissim eros. Aliquam erat volutpat. In hac habitasse platea dictumst. Etiam id iaculis felis. Praesent lacinia in eros in feugiat. Aliquam pharetra convallis nibh vitae accumsan. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus a nunc sit amet nisi gravida fringilla in porta dui. Curabitur a arcu nec quam vulputate vehicula vel sit amet diam. Proin vestibulum, velit sed tempus sollicitudin, velit libero lobortis est, nec suscipit sapien purus ac nulla. Vivamus in vestibulum felis. Nam ultrices semper nisi, a posuere nibh auctor a. Curabitur posuere odio vel pellentesque posuere.
|
||||
|
||||
Proin finibus erat ac blandit pharetra. Nam venenatis arcu nec elit pretium, sit amet luctus quam eleifend. Vestibulum varius a massa in malesuada. Morbi pharetra egestas felis, et vehicula nisl elementum ut. Etiam sit amet magna sit amet nisl pretium pretium in elementum ex. Nam tincidunt risus commodo, sagittis leo a, tristique ex. Aenean vitae tempor turpis. Suspendisse suscipit porttitor facilisis. Aliquam elementum elit ac magna tempus, a luctus magna condimentum. In nibh quam, molestie et nibh a, hendrerit maximus elit. Sed molestie eget magna vitae pellentesque.
|
||||
|
||||
Duis quis aliquet lacus. Nunc iaculis justo ac fermentum luctus. Sed volutpat pellentesque tristique. In porttitor, eros posuere condimentum maximus, arcu augue vestibulum lorem, at tristique mi libero mollis leo. Nunc ut tempus lectus. Maecenas faucibus lorem quis urna auctor tincidunt. Nulla in placerat eros. Vivamus auctor fringilla odio. Maecenas suscipit, ante eu pulvinar ornare, nulla neque suscipit sapien, nec venenatis metus est sit amet sem. Pellentesque feugiat malesuada diam quis malesuada.
|
||||
|
||||
Fusce vel libero vel est ornare sagittis ut ac erat. Vestibulum euismod odio ipsum, eget vestibulum est euismod quis. Cras id neque elementum, dictum odio eget, laoreet metus. Fusce in leo ut sem porta dictum vel eu sem. Pellentesque eget lacus sed neque tincidunt auctor. Fusce libero neque, placerat nec eleifend eu, sagittis vel diam. Quisque et ultrices nisi, id rutrum mi. Aenean consectetur arcu eu lacus molestie finibus.
|
||||
|
||||
Nullam feugiat libero dolor, nec tincidunt lectus eleifend et. Nullam fermentum mauris et odio molestie, vitae suscipit orci pulvinar. Integer egestas orci nibh, rhoncus tristique metus commodo ac. In hac habitasse platea dictumst. Integer at nibh diam. Nam aliquam pulvinar tincidunt. In hac habitasse platea dictumst. Vestibulum fringilla metus ipsum, et vestibulum elit faucibus quis. Vestibulum non purus pellentesque, varius tortor dictum, vehicula nulla. Donec egestas ornare nunc sit amet aliquam. Nunc turpis urna, molestie vestibulum eros eget, elementum ultrices leo. Donec vehicula interdum neque. Morbi imperdiet pharetra urna vel egestas. Morbi nec venenatis dolor. Vivamus elementum accumsan neque lobortis gravida.
|
||||
|
||||
Nunc sapien magna, mattis id convallis ac, luctus vitae diam. Proin viverra mattis mauris vel interdum. Fusce tincidunt condimentum placerat. Nullam feugiat lectus posuere pretium faucibus. Quisque nulla massa, vestibulum at est aliquet, convallis sollicitudin massa. Donec sollicitudin tortor in libero interdum, a aliquam augue interdum. Fusce nunc lorem, gravida sed ex non, tempor porttitor ligula. In scelerisque aliquam ornare.
|
||||
|
||||
Quisque quam elit, laoreet quis placerat id, aliquam vitae risus. Vestibulum vel lorem velit. Integer imperdiet tempor dignissim. Morbi rhoncus odio quis efficitur venenatis. Fusce tristique consequat nulla vitae dapibus. Suspendisse rhoncus nunc non magna ornare lacinia. In lacinia sagittis urna, vitae malesuada lorem tincidunt blandit. Vestibulum a purus tempus orci tristique aliquam in vel nibh. In hac habitasse platea dictumst. Fusce nec diam vitae risus feugiat dignissim.
|
||||
|
||||
Suspendisse quis risus metus. Nam convallis a enim dapibus elementum. Donec at tellus eu sapien laoreet accumsan. Donec ultrices sodales est quis posuere. Mauris posuere turpis non commodo efficitur. Morbi nibh metus, tempor in velit nec, dignissim gravida mi. Suspendisse cursus tempus leo sed aliquam. Morbi nulla ex, facilisis non ante ac, efficitur ullamcorper felis. Phasellus tristique, urna vel finibus iaculis, libero urna viverra erat, sed iaculis lacus felis eget ipsum.
|
||||
|
||||
Donec maximus facilisis gravida. Quisque ac finibus velit. Suspendisse sit amet erat sit amet lorem elementum feugiat ut eu elit. In hac habitasse platea dictumst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer eros elit, consectetur et pretium vitae, convallis vel dui. Nulla maximus nunc a leo auctor, eu hendrerit augue accumsan. Vestibulum eleifend, mi at convallis sollicitudin, dolor lectus lacinia magna, id ullamcorper purus neque eget neque. Nullam vehicula, nisi et interdum hendrerit, lacus ante gravida neque, sit amet volutpat lacus nisi vitae turpis. Nam vel dui a tellus facilisis volutpat. Morbi dignissim venenatis enim, ac dictum magna pellentesque ullamcorper. Nam imperdiet erat nec pellentesque cursus. Cras vel elit pharetra, condimentum magna sed, rhoncus lorem. Aenean nec ipsum eu nunc lacinia sodales id suscipit dolor.
|
||||
|
||||
Fusce a suscipit felis. Nullam condimentum vel urna nec egestas. Curabitur vehicula leo sit amet scelerisque interdum. Morbi ut ultrices tellus. Nunc eleifend, lectus non euismod fermentum, sem libero lacinia augue, sollicitudin rutrum est nunc sed velit. In hac habitasse platea dictumst. Mauris placerat, mi non ornare bibendum, mauris dolor vehicula ante, vitae viverra elit tortor in enim. Proin lectus mi, luctus nec sem id, dignissim rhoncus ipsum. Proin pharetra, velit ac suscipit efficitur, nisi dui dictum mauris, at ultrices ligula eros et diam. Integer lacinia sapien in odio feugiat lacinia. Sed eleifend, enim eu sagittis hendrerit, mi sapien tristique massa, semper rhoncus metus libero sed purus. Vestibulum efficitur, elit sed dictum convallis, nisi turpis dictum justo, ac semper magna felis sed ex. Ut aliquet enim vitae turpis imperdiet, sed pretium nisi commodo. Proin fringilla auctor pretium. Fusce varius dui id nunc euismod, sed varius nulla tempor.
|
||||
|
||||
Vivamus venenatis porta lacus, ac porta ipsum tristique sed. Quisque porttitor elit nec aliquet vehicula. Sed ac ligula mi. Duis purus libero, accumsan id vestibulum vitae, maximus ut erat. Quisque facilisis convallis sapien, et suscipit sapien placerat ut. Sed eleifend risus non eros blandit, eu interdum est egestas. Donec egestas, magna a viverra porta, lectus libero porttitor quam, sit amet mattis libero mauris eu lorem. Donec sollicitudin faucibus lectus, non sodales risus sollicitudin in. Pellentesque vestibulum porttitor ipsum, eget tincidunt elit vestibulum ut. Donec gravida sollicitudin enim et venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent rhoncus magna non volutpat dapibus.
|
||||
|
||||
Nunc quis varius ligula. Ut at ligula convallis, cursus lacus vitae, lobortis arcu. Vivamus nisl lacus, finibus vitae neque vel, luctus faucibus est. Etiam tortor arcu, elementum porta orci tempus, ultricies porta felis. Nullam tellus mi, vulputate sed ante auctor, condimentum consectetur nulla. Aliquam erat volutpat. In sed tristique arcu. Ut blandit dolor in augue vestibulum, sed sollicitudin nisl vestibulum. Quisque magna eros, ornare a viverra sit amet, auctor a tortor. Morbi malesuada, orci at varius placerat, dolor nulla tincidunt magna, nec tincidunt risus urna id magna. Proin faucibus eros metus, sit amet eleifend risus hendrerit sit amet. Nulla in lectus sed est vulputate vehicula quis sed turpis. Curabitur lobortis lectus mattis augue ultrices vehicula. Vestibulum accumsan dictum quam, et feugiat elit.
|
||||
|
||||
Donec commodo eleifend nulla in eleifend. Etiam consectetur lobortis ligula, vel porttitor nibh molestie eget. Sed bibendum, augue vel rhoncus imperdiet, lorem tellus pretium dui, dignissim tincidunt sapien ligula eu nisi. Sed aliquet lacus et purus sodales fermentum. In ex risus, iaculis ut nibh sed, dictum lacinia sapien. Praesent gravida laoreet volutpat. Duis laoreet ligula et libero dignissim tincidunt. Vivamus at mollis lorem, ut laoreet sapien. Nam sem lectus, viverra et maximus vitae, porttitor ut quam.
|
||||
|
||||
Etiam eleifend sem nibh, non euismod ex finibus at. Etiam maximus orci dolor, eu tristique risus venenatis quis. Mauris dignissim ligula quis arcu egestas sollicitudin. Ut ac lacus id velit pellentesque aliquam. Suspendisse pellentesque quam eget venenatis malesuada. Fusce mauris libero, finibus et nisi id, ornare convallis orci. Quisque laoreet, justo non porttitor eleifend, lorem eros tincidunt erat, a eleifend tortor mi eget augue. Sed ligula orci, aliquet ut egestas non, iaculis sed dolor. Aliquam augue nunc, elementum eu sapien vel, ornare vestibulum dui. Etiam cursus lacus in maximus commodo.
|
||||
|
||||
Fusce nibh enim, rutrum condimentum finibus sit amet, mattis id mi. Curabitur sed aliquet sapien, quis aliquet mauris. Morbi ut sem venenatis, eleifend nisl ut, pellentesque augue. Mauris eleifend, eros non fermentum placerat, lectus quam finibus augue, rutrum suscipit neque purus a ipsum. Nulla nec commodo odio. Phasellus bibendum a justo blandit venenatis. Ut id dignissim leo. Quisque nec eleifend justo.
|
||||
|
||||
Fusce scelerisque odio eget molestie ullamcorper. Suspendisse a ligula commodo libero consectetur fermentum ac vel tortor. Mauris malesuada massa nec ultrices bibendum. Fusce sit amet augue nec erat mattis vulputate. Vestibulum venenatis nisi tortor, sit amet viverra nunc laoreet ac. Integer dignissim nisi non sagittis rhoncus. Donec interdum urna vitae nunc lobortis condimentum. Nulla quis tincidunt metus, ut volutpat nisl. Nullam nec eleifend ante. Phasellus a ligula quis lorem venenatis lacinia eget eu magna. Fusce blandit vitae risus a interdum. Donec accumsan massa sit amet lobortis mattis.
|
||||
|
||||
Nullam congue, neque quis aliquam auctor, nulla justo mattis tellus, a fringilla ante metus accumsan sapien. Vivamus fermentum lectus tortor, fringilla vestibulum arcu suscipit non. Nullam malesuada laoreet blandit. Curabitur est quam, rutrum sed interdum vitae, varius vitae turpis. Sed sed consequat ligula. Mauris iaculis nunc at ex viverra, ac molestie ex dapibus. Proin placerat tellus lorem, in malesuada tortor rutrum quis. Ut semper lacus id ornare placerat. Nullam eget laoreet tellus. Sed commodo facilisis suscipit. Phasellus quis tincidunt ex. Aliquam maximus faucibus rhoncus. Sed sollicitudin et urna eget pulvinar. Quisque condimentum rutrum ligula vel pellentesque.
|
||||
|
||||
Fusce convallis velit ut risus fringilla efficitur. Ut pulvinar ultricies mi vitae elementum. Pellentesque eleifend arcu sed est tincidunt convallis. Pellentesque justo ipsum, ultricies ac sapien pulvinar, tincidunt maximus neque. Aliquam tempus luctus arcu. Vestibulum ornare scelerisque ligula, ac maximus turpis mollis vitae. Aliquam lobortis ultricies ultricies. Nunc scelerisque faucibus purus, quis placerat ipsum vulputate in. Sed scelerisque mauris sem, ut convallis risus efficitur sit amet. Fusce sed massa id metus feugiat venenatis non eget massa. Sed sagittis accumsan vulputate. Sed fermentum lacinia risus, in cursus risus scelerisque at. Pellentesque imperdiet risus pharetra dolor egestas, id faucibus purus posuere.
|
||||
|
||||
Curabitur faucibus sapien diam, vel placerat velit lacinia a. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras accumsan scelerisque magna ut ultricies. Nunc auctor dapibus est nec aliquet. Nunc et nulla id erat ultrices tempor nec ut tellus. Cras tempus, tortor ac vulputate aliquet, neque sapien elementum urna, quis vestibulum tellus tortor non tortor. Maecenas egestas urna bibendum lorem egestas eleifend. Aliquam id feugiat ante. Pellentesque rutrum interdum justo vitae feugiat. In mattis nisi ut justo rutrum, a viverra metus porttitor.
|
||||
|
||||
Praesent elementum, metus et dignissim molestie, velit nulla convallis nibh, placerat elementum lorem odio ac tellus. Nulla interdum enim id elit sodales accumsan. Suspendisse lorem enim, blandit a tortor nec, placerat gravida elit. Integer viverra, urna a placerat iaculis, odio nibh pellentesque diam, a vulputate turpis erat ac turpis. Ut pulvinar arcu at ipsum scelerisque viverra. Praesent tempor at tellus nec dapibus. Ut quis sodales ligula. Fusce a leo ex. Vestibulum commodo eu dolor sit amet pellentesque.
|
||||
|
||||
Vestibulum consequat eleifend purus, eu viverra metus tempor quis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean at sodales ante. Sed arcu nisl, sollicitudin quis convallis ut, mattis id augue. Proin velit arcu, fringilla at metus ac, pharetra eleifend orci. Curabitur magna est, lobortis ut magna sed, sagittis bibendum ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sapien quam, ornare non tempor in, fringilla nec velit. Morbi condimentum enim nisl, ut pharetra massa placerat in.
|
|
@ -1,10 +1,11 @@
|
|||
package eu.steffo.cleaver.gui.panels;
|
||||
|
||||
import eu.steffo.cleaver.logic.config.*;
|
||||
import eu.steffo.cleaver.logic.job.Job;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -45,7 +46,7 @@ public class JobsTablePanel extends JPanel {
|
|||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 6;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,9 +55,7 @@ public class JobsTablePanel extends JPanel {
|
|||
case 0: return "Type";
|
||||
case 1: return "File";
|
||||
case 2: return "Split";
|
||||
case 3: return "Crypt";
|
||||
case 4: return "Compress";
|
||||
case 5: return "Progress";
|
||||
case 3: return "Progress";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -76,22 +75,12 @@ public class JobsTablePanel extends JPanel {
|
|||
Job job = jobs.get(rowIndex);
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return job.getType();
|
||||
return job.getTypeString();
|
||||
case 1:
|
||||
return job.getFile().getAbsolutePath();
|
||||
return job.getFileString();
|
||||
case 2:
|
||||
ISplitConfig s = job.getSplitConfig();
|
||||
if(s == null) return "";
|
||||
return s.toString();
|
||||
return job.getProcessString();
|
||||
case 3:
|
||||
ICryptConfig k = job.getCryptConfig();
|
||||
if(k == null) return "";
|
||||
return k.toString();
|
||||
case 4:
|
||||
ICompressConfig c = job.getCompressConfig();
|
||||
if(c == null) return "";
|
||||
return c.toString();
|
||||
case 5:
|
||||
return job.getProgress().toString();
|
||||
}
|
||||
return "Unknown";
|
||||
|
|
|
@ -6,6 +6,6 @@ package eu.steffo.cleaver.logic.config;
|
|||
public class DeflateConfig implements ICompressConfig {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Yes (Deflate)";
|
||||
return "Compress (Deflate)";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class PartsConfig implements ISplitConfig {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d parts", this.parts);
|
||||
return String.format("Split (%d parts)", this.parts);
|
||||
}
|
||||
|
||||
public int getPartCount() {
|
||||
|
|
|
@ -23,6 +23,6 @@ public class PasswordConfig implements ICryptConfig {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "••••••••";
|
||||
return "Encrypt";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class SizeConfig implements ISplitConfig {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d bytes", this.partSize);
|
||||
return String.format("Split (%d bytes)", this.partSize);
|
||||
}
|
||||
|
||||
public long getPartSize() {
|
||||
|
|
|
@ -60,28 +60,38 @@ public class ChopJob extends Job {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
public String getTypeString() {
|
||||
return "Chop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return file;
|
||||
public String getFileString() {
|
||||
return file.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISplitConfig getSplitConfig() {
|
||||
return splitConfig;
|
||||
}
|
||||
public String getProcessString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public ICryptConfig getCryptConfig() {
|
||||
return cryptConfig;
|
||||
}
|
||||
if(compressConfig != null) {
|
||||
s.append(compressConfig.toString());
|
||||
if(cryptConfig != null || splitConfig != null) {
|
||||
s.append(" → ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompressConfig getCompressConfig() {
|
||||
return compressConfig;
|
||||
if(cryptConfig != null) {
|
||||
s.append(cryptConfig.toString());
|
||||
if(splitConfig != null) {
|
||||
s.append(" → ");
|
||||
}
|
||||
}
|
||||
|
||||
if(splitConfig != null) {
|
||||
s.append(splitConfig.toString());
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,7 +115,7 @@ public class ChopJob extends Job {
|
|||
}
|
||||
|
||||
if(cryptConfig instanceof PasswordConfig) {
|
||||
outputStream = new CleaverCryptOutputStream(outputStream, ((PasswordConfig)cryptConfig).getKey());
|
||||
outputStream = new CleaverCryptOutputStream(outputStream, ((PasswordConfig)cryptConfig).getKey().toCharArray());
|
||||
}
|
||||
|
||||
//Create the .chp file
|
||||
|
|
|
@ -36,18 +36,6 @@ public abstract class Job extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name of the job type, such as "Chop" for a {@link ChopJob}.
|
||||
*
|
||||
* It will be displayed in the {@link eu.steffo.cleaver.gui.panels.JobsTablePanel}.
|
||||
*/
|
||||
public abstract String getType();
|
||||
|
||||
/**
|
||||
* @return The file path the job should act on.
|
||||
*/
|
||||
public abstract File getFile();
|
||||
|
||||
/**
|
||||
* @return The current progress of the job.
|
||||
* @see eu.steffo.cleaver.logic.progress.NotStartedProgress
|
||||
|
@ -60,19 +48,19 @@ public abstract class Job extends Thread {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return The {@link IConfig} for the Split step of the job. If {@literal null}, the job shouldn't handle file splitting/merging.
|
||||
* @return The {@link String} that should be displayed in the Type column of the {@link eu.steffo.cleaver.gui.panels.JobsTablePanel Jobs Table}.
|
||||
*/
|
||||
public abstract ISplitConfig getSplitConfig();
|
||||
public abstract String getTypeString();
|
||||
|
||||
/**
|
||||
* @return The {@link IConfig} for the Crypt step of the job. If {@literal null}, the job shouldn't handle file encryption/decryption.
|
||||
* @return The {@link String} that should be displayed in the File column of the {@link eu.steffo.cleaver.gui.panels.JobsTablePanel Jobs Table}.
|
||||
*/
|
||||
public abstract ICryptConfig getCryptConfig();
|
||||
public abstract String getFileString();
|
||||
|
||||
/**
|
||||
* @return The {@link IConfig} for the Compress step of the job. If {@literal null}, the job shouldn't handle file compression/decompression.
|
||||
* @return The {@link String} that should be displayed in the Process column of the {@link eu.steffo.cleaver.gui.panels.JobsTablePanel Jobs Table}.
|
||||
*/
|
||||
public abstract ICompressConfig getCompressConfig();
|
||||
public abstract String getProcessString();
|
||||
|
||||
/**
|
||||
* Set the progress of the job to a different value.
|
||||
|
|
|
@ -9,7 +9,6 @@ import eu.steffo.cleaver.logic.progress.FinishedProgress;
|
|||
import eu.steffo.cleaver.logic.progress.Progress;
|
||||
import eu.steffo.cleaver.logic.progress.WorkingProgress;
|
||||
|
||||
import eu.steffo.cleaver.logic.stream.input.CleaverSplitFileInputStream;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -20,18 +19,15 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.*;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* A {@link Job} that converts <i>chopped</i> (*.chp + *.cXX) files back into regular files.
|
||||
*/
|
||||
public class StitchJob extends Job {
|
||||
private File resultFile;
|
||||
private File chpFile;
|
||||
private ISplitConfig splitConfig = null;
|
||||
private ICryptConfig cryptConfig = null;
|
||||
private ICompressConfig compressConfig = null;
|
||||
private String cryptKey;
|
||||
private File chpFolder;
|
||||
private Document chpDocument;
|
||||
|
||||
/**
|
||||
* Construct a StitchJob, specifying the *.chp file to import the settings from.
|
||||
|
@ -56,7 +52,7 @@ public class StitchJob extends Job {
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct a StitchJob, and additionally specify the {@link Runnable} that should be called on progress updates..
|
||||
* Construct a StitchJob, and additionally specify the {@link Runnable} that should be called on progress updates.
|
||||
* @param chpFile The *.chp file.
|
||||
* @param cryptKey The encryption key to use while decrypting the files.
|
||||
* @param updateTable The {@link Runnable} that should be invoked when {@link #setProgress(Progress)} is called.
|
||||
|
@ -67,43 +63,74 @@ public class StitchJob extends Job {
|
|||
*/
|
||||
public StitchJob(File chpFile, String cryptKey, Runnable updateTable) throws ChpFileError, ProgrammingError {
|
||||
super(updateTable);
|
||||
this.chpFile = chpFile;
|
||||
parseChp(getChpFileDocument(chpFile), cryptKey);
|
||||
this.cryptKey = cryptKey;
|
||||
this.chpDocument = getChpFileDocument(chpFile);
|
||||
this.chpFolder = chpFile.getParentFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
public String getTypeString() {
|
||||
return "Stitch";
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return resultFile;
|
||||
public File getResultFile() {
|
||||
return new File(chpFolder, chpDocument.getElementsByTagName("OriginalFile").item(0).getTextContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISplitConfig getSplitConfig() {
|
||||
return splitConfig;
|
||||
public String getFileString() {
|
||||
return getResultFile().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICryptConfig getCryptConfig() {
|
||||
return cryptConfig;
|
||||
}
|
||||
public String getProcessString() {
|
||||
Element element = (Element)(chpDocument.getDocumentElement().getFirstChild());
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public ICompressConfig getCompressConfig() {
|
||||
return compressConfig;
|
||||
boolean arrow = false;
|
||||
|
||||
while(!element.getTagName().equals("OriginalFile")) {
|
||||
|
||||
if(arrow) {
|
||||
s.append(" → ");
|
||||
}
|
||||
|
||||
String tagName = element.getTagName();
|
||||
switch (tagName) {
|
||||
case "Crypt":
|
||||
s.append("Decrypt");
|
||||
break;
|
||||
case "Deflate":
|
||||
s.append("Decompress (Deflate)");
|
||||
break;
|
||||
case "Fork":
|
||||
s.append(String.format("Merge (%s parts)", element.getAttribute("parts")));
|
||||
break;
|
||||
case "Simple":
|
||||
break;
|
||||
case "Split":
|
||||
s.append(String.format("Merge (%s bytes)", element.getAttribute("part-size")));
|
||||
break;
|
||||
default:
|
||||
s.append("Unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
element = (Element)element.getFirstChild();
|
||||
arrow = true;
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a new {@link Document} based on the contents of a *.chp file.
|
||||
* @param file The *.chp {@link File} to create the document from.
|
||||
* Instantiate a new {@link Document} based on the contents of the passed file.
|
||||
* @param chpFile The file to create a {@link Document} from.
|
||||
* @return The created {@link Document}.
|
||||
* @throws ChpFileError If the .chp does not exist, or is corrupt.
|
||||
* @throws ProgrammingError It should never happen, as the parser should be already configured correctly.
|
||||
*/
|
||||
protected static Document getChpFileDocument(File file) throws ChpFileError, ProgrammingError {
|
||||
protected static Document getChpFileDocument(File chpFile) throws ChpFileError, ProgrammingError {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder;
|
||||
try {
|
||||
|
@ -113,7 +140,7 @@ public class StitchJob extends Job {
|
|||
}
|
||||
Document doc;
|
||||
try {
|
||||
doc = builder.parse(file);
|
||||
doc = builder.parse(chpFile);
|
||||
} catch (SAXException e) {
|
||||
throw new ChpFileError("The .chp is corrupt!");
|
||||
} catch (IOException e) {
|
||||
|
@ -122,41 +149,39 @@ public class StitchJob extends Job {
|
|||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a {@link Element} and create a {@link ICleaverInputStream} based on it.
|
||||
* @param element The {@link Element} to be read.
|
||||
* @param cryptKey The encryption key to use in case a {@link CleaverCryptInputStream} is created.
|
||||
* @throws ChpFileError If there's an error while parsing the node.
|
||||
*/
|
||||
protected ICleaverInputStream parseNode(Element element, String cryptKey) throws ChpFileError {
|
||||
String name = element.getTagName();
|
||||
|
||||
ICleaverInputStream result;
|
||||
|
||||
if(name.equals("Crypt")) {
|
||||
//TODO
|
||||
}
|
||||
else if(name.equals("Deflate")) {
|
||||
//TODO
|
||||
}
|
||||
else if(name.equals("Fork")) {
|
||||
//TODO
|
||||
}
|
||||
else if(name.equals("Simple")) {
|
||||
//TODO
|
||||
}
|
||||
else if(name.equals("Split")) {
|
||||
//TODO
|
||||
}
|
||||
else {
|
||||
throw new ChpFileError("Unknown tag: " + name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//TODO
|
||||
try {
|
||||
Element root = chpDocument.getDocumentElement();
|
||||
Element cleaverNode = (Element)root.getFirstChild();
|
||||
File resultFile = getResultFile();
|
||||
|
||||
InputStream inputStream = ICleaverInputStream.fromElement(cleaverNode, chpFolder, cryptKey);
|
||||
OutputStream outputStream = new FileOutputStream(resultFile);
|
||||
|
||||
//Pipe everything to the output
|
||||
int bytesUntilNextUpdate = 2048;
|
||||
this.setProgress(new WorkingProgress());
|
||||
|
||||
int i;
|
||||
while((i = inputStream.read()) != -1) {
|
||||
outputStream.write(i);
|
||||
bytesUntilNextUpdate -= 1;
|
||||
if(bytesUntilNextUpdate <= 0) {
|
||||
this.setProgress(new WorkingProgress((float)(resultFile.length() - inputStream.available()) / (float)resultFile.length()));
|
||||
bytesUntilNextUpdate = 2048;
|
||||
}
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
|
||||
this.setProgress(new FinishedProgress());
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
this.setProgress(new ErrorProgress(e));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,116 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.KeySpec;
|
||||
|
||||
public class CleaverCryptInputStream extends FilterInputStream implements ICleaverInputStream {
|
||||
private Cipher cipher;
|
||||
|
||||
protected CleaverCryptInputStream(InputStream in) {
|
||||
/**
|
||||
* The algorithm used for the encryption (<a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard">Advanced Encryption Standard</a>).
|
||||
*/
|
||||
private final String encryptionAlgorithm = "AES";
|
||||
|
||||
/**
|
||||
* The mode of operation used for the encryption (<a href="https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Feedback_(CFB)">Cipher FeedBack</a> with 8-bit blocks).
|
||||
*/
|
||||
private final String modeOfOperation = "CFB8";
|
||||
|
||||
/**
|
||||
* The padding standard used for the encryption (<a href="https://en.wikipedia.org/wiki/PKCS">PKCS#5</a>).
|
||||
*/
|
||||
private final String padding = "PKCS5Padding";
|
||||
|
||||
/**
|
||||
* The size in bytes of the <a href="https://en.wikipedia.org/wiki/Salt_(cryptography)">salt</a>.
|
||||
*/
|
||||
private final int saltSize = 8;
|
||||
|
||||
/**
|
||||
* The name of the key derivation algorithm to be used (<a href="https://en.wikipedia.org/wiki/PBKDF2">Password-Based Key Derivation Function 2</a> with <a href="https://en.wikipedia.org/wiki/HMAC">HMAC</a>-<a href="https://it.wikipedia.org/wiki/Secure_Hash_Algorithm>SHA512</a>).
|
||||
*/
|
||||
private final String keyDerivationAlgorithm = "PBKDF2WithHmacSHA512";
|
||||
|
||||
/**
|
||||
* The iteration count for the {@link #keyDerivationAlgorithm}.
|
||||
*/
|
||||
private final int keyIterationCount = 65535;
|
||||
|
||||
/**
|
||||
* The length in bits of the key to be generated with the {@link #keyDerivationAlgorithm}.
|
||||
*/
|
||||
private final int keyLength = 256;
|
||||
|
||||
/**
|
||||
* The size in bytes of the initialization vector.
|
||||
*/
|
||||
private final int ivSize = 16;
|
||||
/**
|
||||
* @return The full transformation string as required by {@link Cipher#getInstance(String)}.
|
||||
*/
|
||||
public String getTransformationString() {
|
||||
return String.format("%s/%s/%s", encryptionAlgorithm, modeOfOperation, padding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a key starting from a character array.
|
||||
* @throws NoSuchAlgorithmException If the {@link #keyDerivationAlgorithm} is invalid.
|
||||
* @throws InvalidKeySpecException If the generated {@link KeySpec} is invalid.
|
||||
*/
|
||||
private SecretKey generatePasswordKey(char[] key, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
KeySpec spec = new PBEKeySpec(key, salt, keyIterationCount, keyLength);
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance(keyDerivationAlgorithm);
|
||||
return factory.generateSecret(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and initialize the {@link Cipher} {@link #cipher} to be used by the CleaverCryptOutputStream.
|
||||
* @param key The string to be used in the {@link Cipher} as encryption key.
|
||||
* @throws NoSuchPaddingException If the {@link #padding} is invalid.
|
||||
* @throws NoSuchAlgorithmException If the {@link #encryptionAlgorithm} is invalid.
|
||||
* @throws InvalidKeySpecException If the generated {@link KeySpec} is invalid.
|
||||
*/
|
||||
private void initCipher(char[] key, byte[] salt, byte[] iv) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, InvalidKeyException {
|
||||
//Setup the cipher object
|
||||
cipher = Cipher.getInstance(getTransformationString());
|
||||
|
||||
//"Convert" the secret key to a AES secret key
|
||||
SecretKey aes = new SecretKeySpec(generatePasswordKey(key, salt).getEncoded(), encryptionAlgorithm);
|
||||
|
||||
//Init the cipher instance
|
||||
cipher.init(Cipher.DECRYPT_MODE, aes, new IvParameterSpec(iv));
|
||||
}
|
||||
|
||||
protected CleaverCryptInputStream(InputStream in, char[] key, byte[] salt, byte[] iv) {
|
||||
super(in);
|
||||
try {
|
||||
initCipher(key, salt, iv);
|
||||
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeySpecException | InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
//This should never happen...
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int encryptedInt = super.read();
|
||||
byte[] encryptedByte = new byte[1];
|
||||
encryptedByte[0] = (byte)encryptedInt;
|
||||
byte[] decryptedByte = cipher.update(encryptedByte);
|
||||
return decryptedByte[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
public class CleaverDeflateInputStream implements ICleaverInputStream {
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
public class CleaverDeflateInputStream extends InflaterInputStream implements ICleaverInputStream {
|
||||
|
||||
/**
|
||||
* Construct a new CleaverDeflateInputStream and ensure the passed {@link InputStream} implements {@link ICleaverInputStream}.
|
||||
* @see InflaterInputStream#InflaterInputStream(InputStream)
|
||||
*/
|
||||
public CleaverDeflateInputStream(InputStream in) {
|
||||
super(in);
|
||||
if(!(in instanceof ICleaverInputStream)) {
|
||||
throw new IllegalArgumentException("The InputStream passed to the CleaverDeflateInputStream must implement ICleaverInputStream.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,66 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
public class CleaverForkFileInputStream implements ICleaverInputStream {
|
||||
import java.io.*;
|
||||
|
||||
public class CleaverForkFileInputStream extends InputStream implements ICleaverInputStream {
|
||||
private final File baseFile;
|
||||
private FileInputStream[] fileInputStreams;
|
||||
private int writeTo;
|
||||
private long partSize;
|
||||
|
||||
public CleaverForkFileInputStream(File baseFile, int parts) throws FileNotFoundException {
|
||||
this.baseFile = baseFile;
|
||||
this.fileInputStreams = new FileInputStream[parts];
|
||||
for(int i = 0; i < parts; i++) {
|
||||
File file = new File(String.format("%s.c%s", baseFile.getAbsolutePath(), i));
|
||||
this.fileInputStreams[i] = new FileInputStream(file);
|
||||
}
|
||||
this.writeTo = 0;
|
||||
this.partSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int b = fileInputStreams[writeTo].read();
|
||||
writeTo += 1;
|
||||
if(writeTo >= fileInputStreams.length) {
|
||||
writeTo = 0;
|
||||
partSize += 1;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base {@link File}.
|
||||
*
|
||||
* The stream will read from multiple files having a name constituted by the base {@link File} name and a *.cXX extension.
|
||||
*
|
||||
* For example, if it is {@literal foo.txt}, the stream will read from {@literal foo.txt.c1}, {@literal foo.txt.c2}, and so on.
|
||||
*
|
||||
* @return The base file.
|
||||
*/
|
||||
public File getBaseFile() {
|
||||
return baseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of bytes read from each part.
|
||||
*/
|
||||
public long getPartSize() {
|
||||
return partSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of file parts to read from.
|
||||
*/
|
||||
public int getParts() {
|
||||
return fileInputStreams.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of the next file where a byte should be read from, starting from 0 to the number of parts -1.
|
||||
*/
|
||||
public int getWriteTo() {
|
||||
return writeTo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
public class CleaverSimpleFileInputStream implements ICleaverInputStream {
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class CleaverSimpleFileInputStream extends FileInputStream implements ICleaverInputStream {
|
||||
private final File baseFile;
|
||||
|
||||
public CleaverSimpleFileInputStream(File baseFile) throws FileNotFoundException {
|
||||
super(String.format("%s.c0", baseFile));
|
||||
this.baseFile = baseFile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class CleaverSplitFileInputStream extends InputStream implements ICleaverInputStream {
|
||||
private final String fileBaseName;
|
||||
private final File baseFile;
|
||||
private long currentByteCount;
|
||||
private long maximumByteCount;
|
||||
private int currentFileCount;
|
||||
|
@ -17,11 +17,13 @@ public class CleaverSplitFileInputStream extends InputStream implements ICleaver
|
|||
|
||||
/**
|
||||
* Construct a SplitFileInputStream.
|
||||
* @param fileBaseName The name of the files without the extension. If it is {@literal example}, the opened files will be {@literal example.c1}, {@literal example.c2}, and so on.
|
||||
* It will read data from the files having the same name as the {@link #baseFile} and a *.cXX extension.
|
||||
*
|
||||
* @param baseFile The {@link File} to be reconstructed.
|
||||
* @param maximumByteCount The number of bytes that should be read from a file before switching to the next one.
|
||||
*/
|
||||
public CleaverSplitFileInputStream(String fileBaseName, long maximumByteCount) {
|
||||
this.fileBaseName = fileBaseName;
|
||||
public CleaverSplitFileInputStream(File baseFile, long maximumByteCount) {
|
||||
this.baseFile = baseFile;
|
||||
this.maximumByteCount = maximumByteCount;
|
||||
this.currentByteCount = 0;
|
||||
this.currentFileCount = 0;
|
||||
|
@ -38,7 +40,7 @@ public class CleaverSplitFileInputStream extends InputStream implements ICleaver
|
|||
}
|
||||
|
||||
currentFileCount += 1;
|
||||
currentFileInputStream = new FileInputStream(String.format("%s.c%d", fileBaseName, currentFileCount));
|
||||
currentFileInputStream = new FileInputStream(String.format("%s.c%d", baseFile.getAbsolutePath(), currentFileCount));
|
||||
currentByteCount = 0;
|
||||
}
|
||||
|
||||
|
@ -58,10 +60,16 @@ public class CleaverSplitFileInputStream extends InputStream implements ICleaver
|
|||
}
|
||||
|
||||
/**
|
||||
* @return The name of the files without the extension. If it is {@literal example}, the opened files will be {@literal example.c1}, {@literal example.c2}, and so on.
|
||||
* Get the base {@link File}.
|
||||
*
|
||||
* The stream will read from multiple files having a name constituted by the base {@link File} name and a *.cXX extension.
|
||||
*
|
||||
* For example, if it is {@literal foo.txt}, the stream will read from {@literal foo.txt.c1}, {@literal foo.txt.c2}, and so on.
|
||||
*
|
||||
* @return The base file.
|
||||
*/
|
||||
public String getFileBaseName() {
|
||||
return fileBaseName;
|
||||
public File getBaseFile() {
|
||||
return baseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,40 @@
|
|||
package eu.steffo.cleaver.logic.stream.input;
|
||||
|
||||
import eu.steffo.cleaver.errors.ChpFileError;
|
||||
import eu.steffo.cleaver.logic.stream.ICleaverStream;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ICleaverInputStream extends ICleaverStream {
|
||||
/**
|
||||
* Construct a ICleaverInputStream from a XML tag.
|
||||
* @param element The XML tag.
|
||||
* @param chpFileDirectory The directory in which the *.chp file is located.
|
||||
* @param key The key to use in case <Crypt> tags are present.
|
||||
*/
|
||||
static InputStream fromElement(Element element, File chpFileDirectory, String key) throws ChpFileError, IOException {
|
||||
String tagName = element.getTagName();
|
||||
switch (tagName) {
|
||||
case "Crypt":
|
||||
InputStream cryptChild = fromElement((Element)element.getFirstChild(), chpFileDirectory, key);
|
||||
return new CleaverCryptInputStream(cryptChild, key.toCharArray(), null, null);
|
||||
case "Deflate":
|
||||
InputStream deflateChild = fromElement((Element)element.getFirstChild(), chpFileDirectory, key);
|
||||
return new CleaverDeflateInputStream(deflateChild);
|
||||
case "Fork":
|
||||
int parts = Integer.parseInt(element.getAttribute("parts"));
|
||||
return new CleaverForkFileInputStream(new File(chpFileDirectory, element.getFirstChild().getTextContent()), parts);
|
||||
case "Simple":
|
||||
return new CleaverSimpleFileInputStream(new File(chpFileDirectory, element.getFirstChild().getTextContent()));
|
||||
case "Split":
|
||||
long partSize = Long.parseLong(element.getAttribute("part-size"));
|
||||
return new CleaverSplitFileInputStream(new File(chpFileDirectory, element.getFirstChild().getTextContent()), partSize);
|
||||
default:
|
||||
throw new ChpFileError("Unknown tag: " + tagName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,50 +17,57 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.security.SecureRandom;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CleaverCryptOutputStream extends FilterOutputStream implements ICleaverOutputStream {
|
||||
private Cipher cipher;
|
||||
private byte[] salt;
|
||||
|
||||
/**
|
||||
* The algorithm used for the encryption (<a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard">Advanced Encryption Standard</a>).
|
||||
*/
|
||||
public static final String ENCRYPTION_ALGORITHM = "AES";
|
||||
private final String encryptionAlgorithm = "AES";
|
||||
|
||||
/**
|
||||
* The mode of operation used for the encryption (<a href="https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Feedback_(CFB)">Cipher FeedBack</a> with 8-bit blocks).
|
||||
*/
|
||||
public static final String MODE_OF_OPERATION = "CFB8";
|
||||
private final String modeOfOperation = "CFB8";
|
||||
|
||||
/**
|
||||
* The padding standard used for the encryption (<a href="https://en.wikipedia.org/wiki/PKCS">PKCS#5</a>).
|
||||
*/
|
||||
public static final String PADDING = "PKCS5Padding";
|
||||
private final String padding = "PKCS5Padding";
|
||||
|
||||
/**
|
||||
* The size in bytes of the <a href="https://en.wikipedia.org/wiki/Salt_(cryptography)">salt</a>.
|
||||
*/
|
||||
public static final int SALT_SIZE = 8;
|
||||
private final int saltSize = 8;
|
||||
|
||||
/**
|
||||
* The name of the key derivation algorithm to be used (<a href="https://en.wikipedia.org/wiki/PBKDF2">Password-Based Key Derivation Function 2</a> with <a href="https://en.wikipedia.org/wiki/HMAC">HMAC</a>-<a href="https://it.wikipedia.org/wiki/Secure_Hash_Algorithm>SHA512</a>).
|
||||
*/
|
||||
public static final String KEY_DERIVATION_ALGORITHM = "PBKDF2WithHmacSHA512";
|
||||
private final String keyDerivationAlgorithm = "PBKDF2WithHmacSHA512";
|
||||
|
||||
/**
|
||||
* The iteration count for the {@link #KEY_DERIVATION_ALGORITHM}.
|
||||
* The iteration count for the {@link #keyDerivationAlgorithm}.
|
||||
*/
|
||||
public static final int KEY_ITERATION_COUNT = 65535;
|
||||
private final int keyIterationCount = 65535;
|
||||
|
||||
/**
|
||||
* The length in bits of the key to be generated with the {@link #KEY_DERIVATION_ALGORITHM}.
|
||||
* The length in bits of the key to be generated with the {@link #keyDerivationAlgorithm}.
|
||||
*/
|
||||
public static final int KEY_LENGTH = 256;
|
||||
private final int keyLength = 256;
|
||||
|
||||
/**
|
||||
* The size in bytes of the initialization vector.
|
||||
*/
|
||||
private final int ivSize = 16;
|
||||
|
||||
/**
|
||||
* @return The full transformation string as required by {@link Cipher#getInstance(String)}.
|
||||
*/
|
||||
public String getTransformationString() {
|
||||
return String.format("%s/%s/%s", ENCRYPTION_ALGORITHM, MODE_OF_OPERATION, PADDING);
|
||||
return String.format("%s/%s/%s", encryptionAlgorithm, modeOfOperation, padding);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +76,7 @@ public class CleaverCryptOutputStream extends FilterOutputStream implements ICle
|
|||
* @return The generated array of secure random bytes.
|
||||
* @see SecureRandom
|
||||
*/
|
||||
protected byte[] generateSecure(int size) {
|
||||
protected static byte[] generateSecure(int size) {
|
||||
byte[] salt = new byte[size];
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
secureRandom.nextBytes(salt);
|
||||
|
@ -81,37 +88,40 @@ public class CleaverCryptOutputStream extends FilterOutputStream implements ICle
|
|||
* @param size The size in bytes of the initialization vector.
|
||||
* @return The generated IV.
|
||||
*/
|
||||
protected IvParameterSpec generateIV(int size) {
|
||||
protected static IvParameterSpec generateIV(int size) {
|
||||
return new IvParameterSpec(generateSecure(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a key starting from a character array.
|
||||
* @throws NoSuchAlgorithmException If the {@link #KEY_DERIVATION_ALGORITHM} is invalid.
|
||||
* @throws NoSuchAlgorithmException If the {@link #keyDerivationAlgorithm} is invalid.
|
||||
* @throws InvalidKeySpecException If the generated {@link KeySpec} is invalid.
|
||||
*/
|
||||
private SecretKey generatePasswordKey(char[] key) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
KeySpec spec = new PBEKeySpec(key, generateSecure(SALT_SIZE), KEY_ITERATION_COUNT, KEY_LENGTH);
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance(KEY_DERIVATION_ALGORITHM);
|
||||
private SecretKey generatePasswordKey(char[] key, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
KeySpec spec = new PBEKeySpec(key, salt, keyIterationCount, keyLength);
|
||||
SecretKeyFactory factory = SecretKeyFactory.getInstance(keyDerivationAlgorithm);
|
||||
return factory.generateSecret(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and initialize the {@link Cipher} {@link #cipher} to be used by the CleaverCryptOutputStream.
|
||||
* @param key The string to be used in the {@link Cipher} as encryption key.
|
||||
* @throws NoSuchPaddingException If the {@link #PADDING} is invalid.
|
||||
* @throws NoSuchAlgorithmException If the {@link #ENCRYPTION_ALGORITHM} is invalid.
|
||||
* @throws NoSuchPaddingException If the {@link #padding} is invalid.
|
||||
* @throws NoSuchAlgorithmException If the {@link #encryptionAlgorithm} is invalid.
|
||||
* @throws InvalidKeySpecException If the generated {@link KeySpec} is invalid.
|
||||
*/
|
||||
private void initCipher(char[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, InvalidKeyException {
|
||||
//Setup the cipher object
|
||||
cipher = Cipher.getInstance(getTransformationString());
|
||||
|
||||
//Generate the salt
|
||||
salt = generateSecure(saltSize);
|
||||
|
||||
//"Convert" the secret key to a AES secret key
|
||||
SecretKey aes = new SecretKeySpec(generatePasswordKey(key).getEncoded(), ENCRYPTION_ALGORITHM);
|
||||
SecretKey aes = new SecretKeySpec(generatePasswordKey(key, salt).getEncoded(), encryptionAlgorithm);
|
||||
|
||||
//Generate the initialization vector
|
||||
IvParameterSpec iv = generateIV(16);
|
||||
IvParameterSpec iv = generateIV(ivSize);
|
||||
|
||||
//Init the cipher instance
|
||||
cipher.init(Cipher.ENCRYPT_MODE, aes, iv);
|
||||
|
@ -123,10 +133,10 @@ public class CleaverCryptOutputStream extends FilterOutputStream implements ICle
|
|||
* @param out The {@link OutputStream} to connect this {@link FilterOutputStream} to.
|
||||
* @param key The desired encryption key.
|
||||
*/
|
||||
public CleaverCryptOutputStream(OutputStream out, String key) {
|
||||
public CleaverCryptOutputStream(OutputStream out, char[] key) {
|
||||
super(out);
|
||||
try {
|
||||
initCipher(key.toCharArray());
|
||||
initCipher(key);
|
||||
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeySpecException | InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
//This should never happen...
|
||||
e.printStackTrace();
|
||||
|
@ -150,33 +160,37 @@ public class CleaverCryptOutputStream extends FilterOutputStream implements ICle
|
|||
element.appendChild(child);
|
||||
|
||||
Attr algorithmAttr = doc.createAttribute("algorithm");
|
||||
algorithmAttr.setValue(ENCRYPTION_ALGORITHM);
|
||||
algorithmAttr.setValue(encryptionAlgorithm);
|
||||
element.setAttributeNode(algorithmAttr);
|
||||
|
||||
Attr modeOfOperationAttr = doc.createAttribute("mode-of-operation");
|
||||
modeOfOperationAttr.setValue(MODE_OF_OPERATION);
|
||||
modeOfOperationAttr.setValue(modeOfOperation);
|
||||
element.setAttributeNode(modeOfOperationAttr);
|
||||
|
||||
Attr paddingAttr = doc.createAttribute("padding");
|
||||
paddingAttr.setValue(PADDING);
|
||||
paddingAttr.setValue(padding);
|
||||
element.setAttributeNode(paddingAttr);
|
||||
|
||||
Attr keyAlgorithmAttr = doc.createAttribute("key-algorithm");
|
||||
keyAlgorithmAttr.setValue(KEY_DERIVATION_ALGORITHM);
|
||||
keyAlgorithmAttr.setValue(keyDerivationAlgorithm);
|
||||
element.setAttributeNode(keyAlgorithmAttr);
|
||||
|
||||
Attr iterationCountAttr = doc.createAttribute("iteration-count");
|
||||
iterationCountAttr.setValue(Integer.toString(KEY_ITERATION_COUNT));
|
||||
iterationCountAttr.setValue(Integer.toString(keyIterationCount));
|
||||
element.setAttributeNode(iterationCountAttr);
|
||||
|
||||
Attr keyLengthAttr = doc.createAttribute("key-length");
|
||||
keyLengthAttr.setValue(Integer.toString(KEY_LENGTH));
|
||||
keyLengthAttr.setValue(Integer.toString(keyLength));
|
||||
element.setAttributeNode(keyLengthAttr);
|
||||
|
||||
Attr ivAttr = doc.createAttribute("iv");
|
||||
ivAttr.setValue(Byte.toString(cipher.getIV()[0]));
|
||||
ivAttr.setValue(Arrays.toString(cipher.getIV()));
|
||||
element.setAttributeNode(ivAttr);
|
||||
|
||||
Attr saltAttr = doc.createAttribute("salt");
|
||||
saltAttr.setValue(Arrays.toString(cipher.getIV()));
|
||||
element.setAttributeNode(saltAttr);
|
||||
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,68 +10,13 @@ import java.util.zip.DeflaterOutputStream;
|
|||
|
||||
public class CleaverDeflateOutputStream extends DeflaterOutputStream implements ICleaverOutputStream {
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream, Deflater, int, boolean)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out, Deflater def, int size, boolean syncFlush) {
|
||||
super(out, def, size, syncFlush);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream, Deflater, int)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out, Deflater def, int size) {
|
||||
super(out, def, size);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream, Deflater, boolean)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out, Deflater def, boolean syncFlush) {
|
||||
super(out, def, syncFlush);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream, Deflater)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out, Deflater def) {
|
||||
super(out, def);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream, boolean)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out, boolean syncFlush) {
|
||||
super(out, syncFlush);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new CleaverCompressOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* Construct a new CleaverDeflateOutputStream and ensure the passed {@link OutputStream} implements {@link ICleaverOutputStream}.
|
||||
* @see DeflaterOutputStream#DeflaterOutputStream(OutputStream)
|
||||
*/
|
||||
public CleaverDeflateOutputStream(OutputStream out) {
|
||||
super(out);
|
||||
if(!(out instanceof ICleaverOutputStream)) {
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverCompressOutputStream must implement ICleaverOutputStream.");
|
||||
throw new IllegalArgumentException("The OutputStream passed to the CleaverDeflateOutputStream must implement ICleaverOutputStream.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,10 @@ public class CleaverForkFileOutputStream extends OutputStream implements ICleave
|
|||
@Override
|
||||
public Element toElement(Document doc) {
|
||||
Element element = doc.createElement("Fork");
|
||||
element.setTextContent(baseFile.getName());
|
||||
|
||||
Element fileElement = doc.createElement("OriginalFile");
|
||||
fileElement.setTextContent(baseFile.getName());
|
||||
element.appendChild(fileElement);
|
||||
|
||||
Attr partSizeAttr = doc.createAttribute("part-size");
|
||||
partSizeAttr.setValue(Long.toString(partSize));
|
||||
|
@ -62,16 +65,18 @@ public class CleaverForkFileOutputStream extends OutputStream implements ICleave
|
|||
/**
|
||||
* Get the base {@link File}.
|
||||
*
|
||||
* The base {@link File} is the one that gives the name to all generated files, including the file parts (*.cXX) and the reconstructed file.
|
||||
* The base {@link File} gives the name to all generated files, including the file parts (*.cXX) and the reconstructed file.
|
||||
*
|
||||
* For example, if it is {@literal foo.txt}, the created files will be {@literal foo.txt.c1}, {@literal foo.txt.c2}, and so on.
|
||||
*
|
||||
* @return The base file.
|
||||
*/
|
||||
public File getBaseFile() {
|
||||
return baseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current maximum size of a part, in bytes.
|
||||
* @return The number of bytes written to each part.
|
||||
*/
|
||||
public long getPartSize() {
|
||||
return partSize;
|
||||
|
|
|
@ -24,7 +24,10 @@ public class CleaverSimpleFileOutputStream extends FileOutputStream implements I
|
|||
@Override
|
||||
public Element toElement(Document doc) {
|
||||
Element element = doc.createElement("Simple");
|
||||
element.setTextContent(baseFile.getName());
|
||||
|
||||
Element fileElement = doc.createElement("OriginalFile");
|
||||
fileElement.setTextContent(baseFile.getName());
|
||||
element.appendChild(fileElement);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ public class CleaverSplitFileOutputStream extends OutputStream implements ICleav
|
|||
* The base {@link File} is the one that gives the name to all generated files, including the file parts (*.cXX) and the reconstructed file.
|
||||
*
|
||||
* For example, if it is {@literal foo.txt}, the created files will be {@literal foo.txt.c1}, {@literal foo.txt.c2}, and so on.
|
||||
*
|
||||
* @return The base file.
|
||||
*/
|
||||
public File getBaseFile() {
|
||||
return baseFile;
|
||||
|
@ -103,7 +105,10 @@ public class CleaverSplitFileOutputStream extends OutputStream implements ICleav
|
|||
@Override
|
||||
public Element toElement(Document doc) {
|
||||
Element element = doc.createElement("Split");
|
||||
element.setTextContent(baseFile.getName());
|
||||
|
||||
Element fileElement = doc.createElement("OriginalFile");
|
||||
fileElement.setTextContent(baseFile.getName());
|
||||
element.appendChild(fileElement);
|
||||
|
||||
Attr partSizeAttr = doc.createAttribute("part-size");
|
||||
partSizeAttr.setValue(Long.toString(maximumByteCount));
|
||||
|
|
Loading…
Reference in a new issue